因?yàn)樵牡貓Dmap、video等層級(jí)較高,其他的組件無法正常顯示,所以使用彈出層用到原生子窗體subNvue
效果如下:

image.png

image.png
用法:
1、在需要使用的頁面(addSamplePage)下新建subNvue文件夾,然后在里面建立相應(yīng)的文件nvue

image.png
2、在pages.json中定義,把樣式什么的直接寫在需要引用的頁面中,例如寫在index頁面里
{
"path": "pages/addSamplePage/addSamplePage",
"style": {
"navigationBarTitleText": "樣品檢測(cè)新增頁",
"app-plus": {
"subNVues": [
{
"id": "video_mask",
"path": "pages/addSamplePage/subnvue/top",
"style": {
"position": "absolute",
"bottom": "0",
"left": "0",
"width": "100%",
"height": "90px",
"background": "transparent"
}
}
]
}
}
}
3.top.nvue頁面
<template>
<div class="wrapper">
<div class="list">
<text class="text" @click="submit('0')">保存</text>
<text class="text" @click="submit('1')">提交</text>
</div>
</div>
</template>
<script>
export default {
data() {
return {
}
},
created() {
},
beforeDestroy() {
},
methods: {
submit(e) {
uni.$emit('drawer-page', e);
},
}
}
</script>
<style>
.wrapper {
position: relative;
flex: 1;
justify-content: center;
align-items: center;
background-color: #fff;
border-color: #eee;
border-style: solid;
border-width: 4px;
}
.list {
position: absolute;
width: 640rpx;
height: 90px;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
.text {
height: 50px;
color: #fff;
background-color: #192c7c;
width: 275rpx;
text-align: center;
line-height: 50px;
border-radius: 25px;
font-size: 30upx;
}
</style>
4.在addSamplePage.vue頁面中使用方法
<script>
export default {
data() {
return {};
},
onLoad() {
// #ifdef APP-PLUS
this.playVideo()
uni.$on('drawer-page', (data) => {
uni.showToast({
title: '點(diǎn)擊了第' + data + '項(xiàng)',
icon: "none"
});
})
// #endif
},
onUnload() {
uni.$off('drawer-page')
},
methods: {
playVideo() {
let subNVue = uni.getSubNVueById('video_mask')
subNVue.show()
}
}
}
</script>
需要注意的是nvue文件中很多css都不支持,文字必須寫在text內(nèi)