• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

uni-app展示富文本包含video,由于video层级过高遮挡住导航栏、菜单等

武飞扬头像
探索未知zxx
帮助1

1、 我的使用场景:是详情下方需要定位一个签到按钮,然后去调用二维码扫一扫功能,但是video层级过高,下滑的时候会盖住按钮,查阅官方发现提供的有解决方案,如nvue、cover-view 组件或subNVue,但是感觉都比较麻烦,因此我选择使用plus.nativeObj.view方法。

onShow(){
	// 绘制视图
	this.view = new plus.nativeObj.View('test', { bottom: '0px', left: '0px', height: uni.upx2px(100)   'px', width: '100%' });
	//在这个view上面画一个矩形,填充白色背景,color: #fff,铺满全屏。
	this.view.drawRect({
	   color: '#fff', top: '0px', left: '0px', width: '100%', height: '100%'
	})
	// 绘制视图2
	this.view2 = new plus.nativeObj.View('aps',{ bottom: uni.upx2px(20)   'px', zIndex: '10', left: 	       
	   '35%', height: uni.upx2px(60)   'px', width: '30%' 
	});
	//给view填充背景。
	this.view2.drawRect(
		{ color: '#dd3131', borderWidth: '2px', radius: uni.upx2px(30)   'px' },
	    { top: '0', left: '0px', width: '100%', height: '100%' }
	);
	//给view加上文字
	let text = ''
	if (this.form.meetingType == '1') {
	   text = `进入视频`
	}
	if (this.form.meetingType == '2') {
	   text = `去签到`
	}
	this.view2.drawText(text, { top: '0px', left: '0px', width: '100%', height: '100%' }, { align: 'center', 'font': uni.upx2px(28)   'px', color: '#fff' });
	this.view.show()
	//给按钮加上点击事件
	this.view2.addEventListener("click", this.nativeClick, false)
	this.view2.show()

},
onUnload () {
    this.closeNativeView()
},
methods(){
	closeNativeView () {
	   //因为只要app端才可以使用这个plus.nativeObj.view,所有这些代码一定要写到uniapp的条件编译中。
	   //#ifdef APP-PLUS
	   this.view.close()
	   this.view2.close()
	   //#endif
	},
}

学新通

2、还有个坑的是,使用.nativeObj.view构建的视图,层级也是很高的,会导致,调出来二维码扫描页面的时候,这个签到按钮仍然存在。此时就需要调用uni.scanCode的时候,要先将nativeObj.view构建的视图关闭。再此之后,还需要在uni.scanCode的fail【接口调用失败的回调函数(识别失败、用户取消等情况下触发)】回调中再次去绘制视图,此时差不多算完全解决了video层级过高的问题

methods(){
	scanCodeFn () {
      this.closeNativeView()
      let that = this
      uni.scanCode({
        scanType: ['qrCode'],
        success: function (res) {
          let params = JSON.parse(JSON.stringify(obj))
          if (params.flag == '2') {
            uni.showToast({
              icon: 'none',
              title: '请去扫签到码!'
            })
            return
          }
          that.signInOrSignOut(JSON.parse(res.result))
        },
        fail: function (res) {
          that.getDetail()
        }
      });
    }
 }
学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgffcfc
系列文章
更多 icon
同类精品
更多 icon
继续加载