1.CommonJS规范 函数调用模式
模块格式:
hello.js
'use strict';
vars ='Hello';
functiongreet(name){
console.log(s +', '+ name +'!');
}
module.exports = greet;
main.js
'use strict';
// 引入hello模块:
vargreet =require('./hello');
vars ='Michael';greet(s);// Hello, Michael!
参考网址:https://www.liaoxuefeng.com/wiki/001434446689867b27157e896e74d51a89c25cc8b43bdb3000/001434502419592fd80bbb0613a42118ccab9435af408fd000
网友评论