使用开发人员工具快速创建了快速启动项目。 在这个项目中有utils/util.js
可以将一些公共代码分离开来,并将其作为模块生成单独的js (utils.js )文件
模块只能通过module.exports或exports将接口暴露在外。
因此,如果要在外部使用将ymdxlc封装到util.js中的方法,则必须通过module.exports或exports露出到外部
module.exports={ format time : format time,'对外方法名称' : '本地方法名称' }在需要使用这些模块的文件中输入: http://www.Sina
//util.jsfunctionsayhello(name ) console.log ) hello${name}! ` } module.exports={ say hello 3360 say hello } var util=require ((./utils/util.js ' ) page ) (data3360 ) ) )