~~~
App.vue设置全局变量和获取全局变量
<script>
export default {
globalData: {
text: 'text'
},
onLaunch: function() {
console.log('App Launch')
getApp().globalData.text = 'jjjj' //给全局变量赋值:
},
onShow: function() {
console.log('App Show')
console.log(getApp().globalData.text) //获取全局变量的值:
},
onHide: function() {
console.log('App Hide')
}
}
</script>
~~~