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

创建一个模块 utils/appConfig.js

1
2
3
4
5
6
7
const appConfig = {
host: 'https://www.baidu.com',
sayHi(e) {
console.log('hi' + e);
}
}
export default appConfig

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

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

获取 App.js

1
2
3
4
5
6
//app.js
App({
userToken:'zhu xiao ming',

/// 省略其他
})
1
2
let app = getApp();
console.log(app.userToken);
  • Post title:微信小程序引入模块,App.js
  • Post author:xxxixxxx
  • Create time:2021-01-14 15:05:00
  • Post link:https://xxxixxx.github.io/2021/01/14/600-微信小程序-引入模块/
  • Copyright Notice:All articles in this blog are licensed under BY-NC-SA unless stating additionally.
 Comments