标签:cti 项目结构 install 编写 row 第一步 comm 目录 type
|-js
  |-dist //生成编译完js的目录
  |-src //源码所在的目录(我们编写的、没经过工具处理的代码,叫做源码)
    |-module1.js
    |-module2.js
    |-module3.js
    |-main.js
|-index.html
module1.js
module.exports = {
  foo() {
    console.log(‘moudle1 foo()‘)
  }
}
module2.js
module.exports = function () {
  console.log(‘module2()‘)
}
module3.js
exports.foo = function () {
  console.log(‘module3 foo()‘)
}
exports.bar = function () {
  console.log(‘module3 bar()‘)
}
下载第三方模块uniq:打开左下角的Terminal,cd到02_CommonJS-Node路径,输入命令:npm install uniq --save
main.js
//引用模块
let module1 = require(‘./module1‘)
let module2 = require(‘./module2‘)
let module3 = require(‘./module3‘)
let uniq = require(‘uniq‘)
//使用模块
module1.foo()
module2()
module3.foo()
module3.bar()
console.log(uniq([1, 3, 1, 4, 3]))
npm install browserify -gbrowserify js/src/main.js -o js/dist/bundle.js<script type="text/javascript" src="js/dist/bundle.js"></script> 
标签:cti 项目结构 install 编写 row 第一步 comm 目录 type
原文地址:https://www.cnblogs.com/fsg6/p/13143351.html