@@ -19,45 +19,47 @@ export default {
1919 title: ' nav-dot'
2020 };
2121 },
22- onLoad () {
22+ onReady () {
2323 this .setStyle (0 ,true );
24- this .setStyle (1 ,' 20 ' );
24+ this .setStyle (1 ,true , ' 9 ' );
2525
2626 },
2727 methods: {
2828 /**
2929 * 修改导航栏buttons
30- * index[number] 修改的buttons 下标索引,最右边索引为0
31- * text[boolean|string] 需要修改的text 内容 ,如果定义redDot请设置 true||false ,如果定义badgeText请设置具体数字,如果没有输入''
30+ * index[number] 修改的buttons 下标索引,最右边索引为0
31+ * show[boolean] 显示还是隐藏角标或者红点
32+ * text[string] 需要修改的角标的text 内容 ,如果定义redDot 此参数无效 ,如果定义badgeText请设置具体,如果不用输入
3233 */
33- setStyle (index , text ) {
34+ setStyle (index , show , text ) {
3435 let pages = getCurrentPages ();
3536 let page = pages[pages .length - 1 ];
3637 // #ifdef APP-PLUS
3738 let currentWebview = page .$getAppWebview ();
38- let titleNView = currentWebview .getStyle ().titleNView ;
39-
40- let dot = titleNView .buttons [index].redDot ;
41- let badgeText = titleNView .buttons [index].badgeText ;
42- if (dot) {
43- titleNView .buttons [index].redDot = text;
44- }
45- if (badgeText) {
46- titleNView .buttons [index].badgeText = text;
39+ if (show){
40+ if (index === 0 ){
41+ currentWebview .showTitleNViewButtonRedDot ({index: index,text: text})
42+ }else {
43+ currentWebview .setTitleNViewButtonBadge ({index: index,text: text})
44+ }
45+ }else {
46+ if (index === 0 ){
47+ currentWebview .hideTitleNViewButtonRedDot ({index: index})
48+ }else {
49+ currentWebview .removeTitleNViewButtonBadge ({index: index})
50+ }
4751 }
48- currentWebview .setStyle ({
49- titleNView: titleNView
50- });
52+
5153 // #endif
5254 }
5355 },
5456 onNavigationBarButtonTap (e ) {
5557 uni .showToast ({
56- title: e .index === 0 ? ' 你点了消息按钮' : ' 你点了关注按钮' ,
58+ title: e .index === 0 ? ' 你点了消息按钮' : ' 你点了关注按钮' ,
5759 icon: ' none'
5860 });
5961 // 取消红点或者角标
60- this .setStyle (e .index , e . index === 0 ? false : ' ' );
62+ this .setStyle (e .index ,false );
6163 },
6264 components: {
6365 uniIcon
0 commit comments