Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试从所需的文件 Account.js 创建一个对象。Node.js 在线显示错误var test = new account();:未定义帐户。我在这里做错了什么?
var test = new account();
// Account.js module.exports = function Account() { console.log("THIS SHOULD WORK"); } // app.js require('./Account'); var test = new Account();
请注意, require 不像importor include。这就是你所缺少的:
import
include
// app.js var Account = require('./Account'); var test = new Account();