page.json
{
"path" : "pages/content/detail-article/detail-article",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false,
"app-plus": {
"titleNView": {
"buttons": [{
"type": "share"
},
{
"text": "\ue505",
"fontSrc": "/static/iconfont.ttf",
"fontSize": "22px"
}
]
}
}
}
}
页面里:
onNavigationBarButtonTap(event) {
const buttonIndex = event.index;
if (buttonIndex === 1) {
console.log('收藏');
//这里要调用接口,设置this.isStar的值,下面代码是设置图标用的
// #ifdef APP-PLUS
var currentWebview = this.$mp.page.$getAppWebview();
var tn = currentWebview.getStyle().titleNView;
var text = tn.buttons[1].text;
console.log(this.isStar);
if(this.isStar){
tn.buttons[1].text = '\ue505';
this.isStar = false;
}else{
tn.buttons[1].text = '\ue630';
this.isStar = true;
}
currentWebview.setStyle({
titleNView: tn
});
// #endif
}
}