因为有业务需求动态隐藏 所以特此写了App和H5情况的显示隐藏  复制即可用

// #ifdef APP
let webView = that.$mp.page.$getAppWebview();
webView.setTitleNViewButtonStyle(0,{
  width: '0'  
});
// #endif
// #ifdef H5
document.querySelector('.uni-page-head .uni-page-head-ft .uni-page-head-btn').setAttribute("style","display:none")
// #endif
// #ifdef H5
			this.$nextTick(() => {
				// 使用 nextTick 确保 DOM 存在
				const btn = document.querySelector('.uni-page-head .uni-page-head-ft .uni-page-head-btn');
				if (btn) {
					btn.style.display = this.sysType == 1 ? 'block' : 'none';
					console.log(btn,'btn');
					
				} else {
					setTimeout(() => {
						const retryBtn = document.querySelector('.uni-page-head .uni-page-head-ft .uni-page-head-btn');
						console.log(retryBtn, 'retryBtn');
						if (retryBtn) retryBtn.style.display = this.sysType == 1 ? 'block' : 'none';
					}, 50);
				}
			});
			// #endif
// #ifdef H5
this.$nextTick(() => {
   document.querySelector('.uni-page-head .uni-page-head-ft .uni-page-head-btn').setAttribute("style", "display: " + (this.sysType == 1 ? 'block' : 'none'))
});
// #endif
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐