美文网首页
微信小程序引入模块,获取 App.js

微信小程序引入模块,获取 App.js

作者: xxxixxxx | 来源:发表于2021-01-14 15:12 被阅读0次

创建一个模块 utils/appConfig.js

const appConfig = {
  host: 'https://www.baidu.com',
  sayHi(e) {
    console.log('hi' + e);
  }
}
export default appConfig

导入创建的模块使用 其他 .js 文件内

import appConfig from '../../../utils/appConfig.js';
console.log(appConfig.host);
appConfig.sayHi('朱小明')

获取 App.js

//app.js
App({
  userToken:'zhu xiao ming',

  /// 省略其他
  })
let app = getApp();
console.log(app.userToken);

获取更多小程序相关文章

相关文章

网友评论

      本文标题:微信小程序引入模块,获取 App.js

      本文链接:https://www.haomeiwen.com/subject/czsvaktx.html