Skip to content

subNvue在vue页面正常生效,在nvue页面中不生效? #1308

Closed
@zhongku

Description

@zhongku

问题描述

我们用subNvue的时候,如果页面是vue格式可以正常生效,如果是nvue页面则不生生效?

苹果真机运行时报错

TypeError: uni.getSubNVueById is not a function. (In 'uni.getSubNVueById('twonav')', 'uni.getSubNVueById' is undefined) __ERROR

问题

  1. subNvue是否可以在nvue页面中使用,我看了下hello 那个demo是在vue页面中使用的?
  2. 如果能使用:为什么会报 uni.getSubNVueById is not a function 错误
  3. 如果不能使用,除了将页面改成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">&#xe582;</text>
			<text class="title">nvue 渐变色标题栏</text>
		</div>
    </div>
</template>

<script>
    export default {
		data() {
			return {}
		},
		beforeCreate() {
		},
		methods: {
			back() {
				uni.navigateBack()
			}
		}
	}
</script>

Activity

HooeyPooey

HooeyPooey commented on Jun 10, 2020

@HooeyPooey

uniapp开发微信小程序遇到类似的问题,“Uncaught TypeError: uni.getCurrentSubNVue is not a function”

GRCmade

GRCmade commented on Mar 19, 2025

@GRCmade
Collaborator

官方不再维护nvue,建议升级uni-app x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Otto-J@HooeyPooey@zhongku@GRCmade

        Issue actions

          subNvue在vue页面正常生效,在nvue页面中不生效? · Issue #1308 · dcloudio/uni-app