弄月
弄月
  • 发布:2020-02-05 13:10
  • 更新:2020-10-13 12:00
  • 阅读:3663

动态修改TitleNView RedDot,支持App 和 H5

分类:uni-app

app部分来自于 https://github.com/dcloudio/hello-uniapp

export function setTitleNViewStyle(index, show,text) {  
    let pages = getCurrentPages();  
    let page = pages[pages.length - 1];  
    // #ifdef APP-PLUS  
    let currentWebview = page.$getAppWebview();  
    if(show){  
        if(index === 0){  
            currentWebview.showTitleNViewButtonRedDot({index:index,text:text})  
        }else{  
            currentWebview.setTitleNViewButtonBadge({index:index,text:text})  
        }  
    }else{  
        if(index === 0){  
            currentWebview.hideTitleNViewButtonRedDot({index:index})  
        }else{  
            currentWebview.removeTitleNViewButtonBadge({index:index})  
        }  
    }  
    // #endif  

    // #ifdef H5  
    if(show){  
        if(index === 0){  
            document.querySelectorAll('.uni-page-head-hd .uni-page-head-btn')[1].classList.add('uni-page-head-btn-red-dot');  
        } else {  
            document.querySelector('.uni-page-head-ft .uni-page-head-btn').classList.add('uni-page-head-btn-red-dot');  
        }  
    } else {  
        if(index === 0){  
            document.querySelector('.uni-page-head-btn-red-dot').classList.remove('uni-page-head-btn-red-dot');  
        } else {  
            document.querySelector('.uni-page-head-ft .uni-page-head-btn-red-dot').classList.remove('uni-page-head-btn-red-dot');  
        }  
    }  
    // #endif  
}  
1 关注 分享
5675557

要回复文章请先登录注册

蹦豆儿

蹦豆儿

h5里,text这个文字为啥不显示?
2020-10-13 12:00
风云杭州

风云杭州

挺不错
2020-08-01 16:29
Basil

Basil

非常感谢
2020-06-11 11:24
5675557

5675557

感谢分享
2020-04-23 05:04