微信小程序页面获取全局变量的案例:
app.js文件代码:
App({globalData{
test:"hello world"
}
})
index.js文件代码:
var app =getApp()Page({
test:null
})
onLoad: function (options) {
this.setData({
test:app.globalData.test
})
}
index.wxml文件代码:
<view>{{test}}</view>
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:微信小程序怎么修改全局变量