圖片.png
根據(jù)mode判斷修改衰伯,兩個(gè)問(wèn)題,包含樣式的切換闰歪、語(yǔ)言的切換
reason
onShow --------- 監(jiān)聽(tīng)頁(yè)面顯示嚎研。頁(yè)面每次出現(xiàn)在屏幕上都觸發(fā),包括從下級(jí)頁(yè)面點(diǎn)返回露出當(dāng)前頁(yè)面
1.進(jìn)入頁(yè)面時(shí)库倘,修改標(biāo)題临扮,在onShow中執(zhí)行需要延遲一個(gè)小時(shí)時(shí)間
2.進(jìn)入頁(yè)面,樣式修改教翩,在onShow中執(zhí)行同樣有延遲
onShow(){
// #ifdef APP-PLUS
var style = plus.navigator.getUiStyle();
if('dark'==style){
console.log('dark')
uni.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: '#1f1f1f',
animation: {
duration: 400,
timingFunc: 'easeIn'
}
})
}else{
uni.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: '#EA8C1B',
animation: {
duration: 400,
timingFunc: 'easeIn'
}
})
}
// #endif
},
官方指出
onShow杆勇、onLoad、onReady
頁(yè)面A第一次入棧的執(zhí)行順序: onLoad >= onShow >= onReady
當(dāng)進(jìn)入子頁(yè)面B使用 uni.navigateBack();返回頁(yè)面A時(shí)饱亿,
頁(yè)面A執(zhí)行的只有onShow
3.對(duì)于在App端動(dòng)態(tài)修改原生導(dǎo)航欄----https://ask.dcloud.net.cn/article/35374,使用的方法有改動(dòng)
button位置的修改
舊版本的寫法
let currentWebview = page.$getAppWebview();
let titleObj = currentWebview.getStyle().titleNView;
if (!titleObj.buttons) {
return;
}
if(prevPage.route=="pages/taber/home"){
titleObj.buttons[1].text = this.i18n.index.Home;
}else{
titleObj.buttons[1].text = '';
}
currentWebview.setStyle({
titleNView: titleObj
});
//更新后的
var webView = this.$mp.page.$getAppWebview();
// 修改buttons
// index: 按鈕索引, style {WebviewTitleNViewButtonStyles }
webView.setTitleNViewButtonStyle(1, {
text: this.i18n.index.Home,
});