uni-app原生导航栏字体图标变成问号
项目中向根据视频是否播放来控制导航栏中一个button是否显示,在一开始是这么写的
isPlay: {
immediate: true,
handler(isPlay) {
//#ifdef APP-PLUS
var currentWebview = this.$mp.page.$getAppWebview();
if (isPlay) {
currentWebview.setTitleNViewButtonStyle(3, {
width: '60px'
})
} else {
currentWebview.setTitleNViewButtonStyle(3, {
width: '0'
})
}
//#endif
}
}
一开始在监听中是这样写的,在安卓中能正常跑,但是在ios端就出问题了。原生导航栏中的字体图标变成了问号
在网上想找解决方法也没又找到有效的,最后发现了监听这里可能会有问题,注释这段代码后就显示正常了,但还是需要监听button显示,所以换了写法。
isPlay: {
immediate: true,
handler(isPlay) {
console.log('isPlay', isPlay)
//#ifdef APP-PLUS
var currentWebview = this.$mp.page.$getAppWebview();
var tn = currentWebview.getStyle().titleNView;
tn.buttons[3].text = isPlay ? "\ue607" : "";
tn.buttons[3].background = isPlay ? "rgba(0,0,0,0.5)" : "rgba(0,0,0,0)"
currentWebview.setStyle({
titleNView: tn
});
//#endif
}
}
最后,终于好了。