uniapp 切换语言原生导航栏buttons文字不生效?
效果图

场景:在 tabbar 页面中,配置 原生导航栏 buttons ,切换语言时,不会实时更新问题。
page.json配置
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "%common.index%",
"enablePullDownRefresh": true,
"app-plus": {
"titleNView": {
"backgroundImage": "linear-gradient(to right, #fe8c00, #f83600);",
"buttons": [{
"text": "%common.devices%",
"color": "#fff",
"fontSize": "18",
"width": 100,
"float": "left"
},
{
"text": "\ue600",
"color": "#fff",
"fontSize": "26",
"width": 60,
"float": "right",
"fontSrc": "/static/iconfont/iconfont.ttf"
}
}
}
}
}
解决方式
这里用简单粗暴方式,在
onShow调用方法,获取当前webview对象,使用国际化 再次设置buttons,以达更新实时文案。欢迎分享其他方案~
let webView = this.$mp.page.$getAppWebview();
webView.setTitleNViewButtonStyle(0, {
text: this.$t('common.devices')
});
文章讲述了在uniapp中,如何在tabbar页面的原生导航栏配置中,当切换语言时按钮文字不更新的问题,提供了解决方案:在onShow事件中获取webview对象,使用国际化API重新设置按钮文案。

5711

被折叠的 条评论
为什么被折叠?



