在pages.json页面
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#000000",
"app-plus": {
"bounce": "none"
}
}
}
在页面的onLoad中
let pages = getCurrentPages()
let page = pages[pages.length - 1];
let currentWebview = page.$getAppWebview();
let titleNView = currentWebview.getStyle().titleNView
titleNView.autoBackButton = false//隐藏返回按钮
currentWebview.setStyle({
titleNView: titleNView
})
let titleNView = currentWebview.getStyle().titleNView
console.log(titleNView)
//打印结果
{
"autoBackButton": true,
"backgroundColor": "#F8F8F8",
"dock": "top",
"height": 44,
"position": "dock",
"statusbar": {},
"tags": [],
"titleColor": "#000000",
"titleText": "纸板入库",
"type": "default"
}
设置延时
titleNView.autoBackButton = true
currentWebview.setStyle({
titleNView: titleNView
})
uni.setNavigationBarColor({
frontColor: "#ffffff", //文字颜色
backgroundColor: "#000000" ,//底部背景色
})
uni.setNavigationBarTitle({
title: title//想要显示的顶部标题
});
参考自https://blog.youkuaiyun.com/weixin_39389758/article/details/108757470