1 Star 0 Fork 0

yangxiong1/uni-app-first

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
App.vue 967 Bytes
一键复制 编辑 原始数据 按行查看 历史
yangxiong1 提交于 2021-04-12 18:51 . first init
<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>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/yangxiong1/uni-app-first.git
git@gitee.com:yangxiong1/uni-app-first.git
yangxiong1
uni-app-first
uni-app-first
master

搜索帮助