sllzhj

1、先建立一个common.js, 写我们的外部js

  比如: common.js  

function getTime(){
  //下面写我们的代码  
    ....
}

function getCity(){
 //下面写我们的代码  
    ....
}
module.exports = { //必须在这里暴露接口,以便被外界访问,不然就不能访问
   getTime: getTime,
    getCity:getCity
}

2、在需要引入js文件的js中写

var commonJS= require("common.js");

 onLoad: function (options) {
    this.setData({
     time: commonJS.getTime() // 最后在这里生效
    })
  },

 

分类:

技术点:

相关文章:

  • 2021-11-04
  • 2021-11-04
  • 2021-11-03
  • 2021-11-07
  • 2021-12-08
  • 2021-11-13
  • 2021-11-03
猜你喜欢
  • 2021-11-03
  • 2021-12-08
  • 2021-12-08
  • 2021-11-28
  • 2021-12-13
  • 2021-10-01
  • 2021-11-03
相关资源
相似解决方案