首页 web前端 Flex布局 Grid布局 工具 在线编辑器 关于
2020-07-08 01:27 2023-12-04 14:12 标签:nodejs
<script type="text/javascript" src="test.js"></script>
require("test.js");
var res = require("foo.js");
foo.js
var a = 1;
function say(){
console.log(a);
}
exports.a = a;
exports.say = say;
index.js
var foo = require(foo.js);
console.log(foo.a);
view.js
function View(){
}
View.prototype.test = function(){
console.log('test')
}
View.test1 = function(){
console.log('test1')
}
moudle.exports = view;
test.js
var x = require('./foo');
console.log(x) 结果:{ [Function: View] test1: [Function] }
console.log(x.test) 结果:undefined
console.log(x.test1) 结果:[Function]
x.test1() 结果:test1