require
require 是 Commonjs 的规范,node 应用是由模块组成的,遵从 commonjs 的规范。用法:
a.js
function test(args) {
// body...
console.log(args);
}
module.exports = {
test,
};
b.js
let { test } = require("./a.js");
test("this is a test.");
require 是 Commonjs 的规范,node 应用是由模块组成的,遵从 commonjs 的规范。用法:
a.js
function test(args) {
// body...
console.log(args);
}
module.exports = {
test,
};
b.js
let { test } = require("./a.js");
test("this is a test.");