Closed
Description
问题描述
我们用subNvue的时候,如果页面是vue格式可以正常生效,如果是nvue页面则不生生效?
苹果真机运行时报错
TypeError: uni.getSubNVueById is not a function. (In 'uni.getSubNVueById('twonav')', 'uni.getSubNVueById' is undefined) __ERROR
问题
- subNvue是否可以在nvue页面中使用,我看了下hello 那个demo是在vue页面中使用的?
- 如果能使用:为什么会报 uni.getSubNVueById is not a function 错误
- 如果不能使用,除了将页面改成vue格式的以外还有什么其他解决方案?
pages.json源码 以及目录
{
"path": "pages/tabbar/two",
"style": {
"navigationBarTitleText": "测试一",
"enablePullDownRefresh": true,
"titleNView": false,
"pullToRefresh": {
"style": "circle",
"color": "#FD575C",
"offset": "50px"
},
"subNVues": [{
"id": "twonav",
"path": "pages/tabBar/subnvue/two",
"type": "popup",
"style": {
"position": "dock",
"dock": "top",
"width": "100upx",
"height": "150upx",
"background": "transparent"
}
}]
}
}
页面two.nvue源码
<template>
<view>
<text>测试</text>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onReady() {
const subNVue = uni.getSubNVueById('twonav')
console.log('subNVue', subNVue)
},
mounted() {
},
methods: {
}
}
</script>
subnvue/two.nvue源码
<template>
<div class="wrapper">
<div class="status-bar"></div>
<div class="nav">
<text class="back" @click="back"></text>
<text class="title">nvue 渐变色标题栏</text>
</div>
</div>
</template>
<script>
export default {
data() {
return {}
},
beforeCreate() {
},
methods: {
back() {
uni.navigateBack()
}
}
}
</script>
Activity
HooeyPooey commentedon Jun 10, 2020
uniapp开发微信小程序遇到类似的问题,“Uncaught TypeError: uni.getCurrentSubNVue is not a function”
GRCmade commentedon Mar 19, 2025
官方不再维护nvue,建议升级uni-app x