fightjianxian

在app.js中设置需要的全局变量的参数,比如公司名称等

//app.js
App({
    globalData: {
        title: \'tomatocc\'
    }
})

然后就可以在某个页面的js文件中(比如index.js)的data数组里面去直接使用app.js中配置的全局变量了。

Page({
    data: {
        text: getApp().globalData.title
    }
})
或者
const app = getApp();
Page({
    data:{
        text:app.title
    }
})

 

 

 

 

 

 

.

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-19
  • 2022-12-23
  • 2022-12-23
  • 2022-03-03
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2021-08-13
  • 2022-12-23
  • 2021-04-07
  • 2021-06-06
相关资源
相似解决方案