代码拉取完成,页面将自动刷新
<script>
//应用级别的生命周期监听函数在这里配置
//全局变量在globalData中配置
export default {
onLaunch: function() {
console.log('App Launch')
},
onShow: function() {
console.log('App Show')
this.controlTimer(true)
},
onHide: function() {
console.log('App Hide')
this.controlTimer(false)
},
globalData:{
user:{
id:1,
name:'杨雄',
},
demoTitle:'uni-app培训演示',
timer:null
},
methods:{
controlTimer(param){
console.log('controlTimer invoked')
//关于globalData的取值、赋值在App.vue中可以这样操作,但是在其他页面只能通过getApp().globalData来操作
if(param){
this.globalData.timer =setInterval(()=>{
console.log('每2秒执行我一次',new Date())
},2000)
}else{
clearInterval(this.globalData.timer)
this.globalData.timer=null
}
}
}
}
</script>
<style>
/*每个页面公共css */
</style>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。