模块化

模块化

  • 不使用模块化

  • 使用模块化

  • AMD

  • CommonJS

  • ES6

不使用模块化

  • util getFormatDate函数

  • a-util.js aGetFormatDate函数 使用getFormatDate

  • a.js aGetFormatDate

  • 定义

//util.js
function getFormatDate(date,type) {
  //type === 1返回 2017-06-15
  //type === 2返回 2017年6月15日 格式
  //...
}
//a-util.js
function aGetFormatDate(data) {
  //返回
  return getFormatDate(date,2);
}
// a.js
var dt = new Date()
console.log(aGetFormatDate(dt));
  • 使用

使用模块化

最后更新于

这有帮助吗?