1、manifest.json源码配置
{
"app-plus" : {
"splashscreen" : {
"alwaysShowBeforeRender" : false,
"waiting" : true,
"autoclose" : false,
"delay" : 0
}
}
}
2、app.vue 中 onLaunch 配置
onLaunch: function () {
//应用初始化完成触发(只触发一次)
const token = uni.getStorageSync('token');//获取token
if (token) {
//存在则关闭启动页进入首页
plus.navigator.closeSplashscreen();
} else {
//不存在则跳转至登录页
uni.reLaunch({
url: "/pages/login/index",
success: () => {
plus.navigator.closeSplashscreen();
}
})
}
},
3、pages.json 配置
首页正常配置,登录页随便放哪里(不能放第一个)
{
pages: [
{
"path":"pages/home/index",
"style": {
"navigationBarTitleText": "首页",
"navigationStyle":"custom"
}
},
{
"path": "pages/login/index",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle":"custom"
}
}
]
}