在使用uniapp的时候经常会发现有的内容如video层级过高而导致的样式问题,我们可以使用subNVues来解决这个问题,这边文章用于记录如何向subNVues内传值。
首先是配置我们页面的subNVues。
{
"path" : "pages/index/index",
"style" :
{
"navigationBarTitleText": "测试",
"enablePullDownRefresh": false,
"app-plus":{
"subNVues":[{
"id":"subNVuesPage",// 对应的subNVues页面的id,即该页面的第一个view的id
"path":"pages/index/subNVues",// subNVues路径
"type":"popup",// subNVues类型
"style":{// subNVues样式
"margin":"auto",
"width":"100%",
"height":"100%",
"background":"transparent"
}
}]
}
}
}
注意subNVues页面中第一个view的id:
<template>
<view id="subNVuesPage">
<text>
{{title}}
</text>
</view>
</template>
页面间的传值:
index页面中
uni.$emit('sendNum', {
num:1,
title:"这是标题一"
});
subNVues页面中
data() {
return {
number:0,
title:""
}
},
onLoad(){
// 监听事件
uni.$on('sendNum',(res)=>{
this.number=res.num
this.title=res.title
})
},
onUnload() {
// 移除监听事件
uni.$off('sendNum');
},