uniapp自定义顶部右侧菜单原创

原创
小哥 3年前 (2022-10-22) 阅读数 57 #大杂烩

//pages.json中
{
"path": "pages/shopCart/shopCart",
"style": {
"navigationBarTitleText": "购物车",
"app-plus": {
"titleNView": {
"buttons": [{
// #ifdef APP-PLUS
"text": "编辑",
// #endif
"fontSize": "16",
"color": "#b6b6b6",
"width": 70
}],
"splitLine": {//导航栏下划线
"color": "#F4f4f4",
"height": "1px"
}
}
}
}
},
//导航栏按钮事件
onNavigationBarButtonTap(e) {
var index = e.index;
// 更改按钮文本所需的
// #ifdef APP-PLUS
var currentWebview = this.$mp.page.$getAppWebview();
var tn = currentWebview.getStyle().titleNView;
console.log(tn);
var text = tn.buttons[0].text;
console.log(text);
if (text == 编辑) {
this.cartStatus = true;
tn.buttons[0].text = 完成;
currentWebview.setStyle({
titleNView: tn
});
} else if (text == 完成) {
this.cartStatus = false;
tn.buttons[0].text = 编辑;
currentWebview.setStyle({
titleNView: tn
});
}
// #endif
},

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除

热门