App.vue
<script>
export default {
onLaunch: function() {
uni.redirectTo({ url: '/pages/index/index' })
console.log('App Launch')
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<style>
/*每个页面公共css */
</style>
launch.vue
<template>
<view>启动页 </view>
</template>
<script setup lang="ts">
import { onLoad, onUnload } from '@dcloudio/uni-app'
onLoad(() => {
console.log('launch onLoad')
uni.showLoading({
title: '加载中',
mask: true
})
})
onUnload(() => {
console.log('launch onUnload')
uni.hideLoading()
})
</script>
<style scoped lang="scss"></style>
index.vue
<template>
<view>主页</view>
</template>
<script setup lang="ts">
</script>
<style lang="scss" scoped>
</style>
//页面顺序
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
"path" : "pages/launch/launch",
"style" :
{
"navigationBarTitleText" : "",
"enablePullDownRefresh" : false
}
},
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "uni-app"
}
}
]
coderH (作者)
步骤错了 页面跳转在onLaunch里面执行,不是手动触发 然后运行起来你看一下是不是loading弹窗一直都在
2024-02-22 13:29
套马杆的套子
回复 1***@qq.com: 额...你先研究下App.vue和界面生命周期的顺序吧,,按照你说的,在app.vue中的onLaunch去跳转B界面,那A界面都没加载呢,怎么执行A的onUnload?
2024-02-22 13:48