8***@qq.com
8***@qq.com
  • 发布:2021-04-25 15:10
  • 更新:2021-04-26 10:26
  • 阅读:616

【报Bug】版本:3.1.11.20210423, uni.createSelectorQuery()报错

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10 64位 专业版

HBuilderX类型: 正式

HBuilderX版本号: 3.1.11

手机系统: Android

手机系统版本号: Android 11

手机厂商: 华为

手机机型: Mate 30

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
mounted() {  
        console.log("mounted")  
        setTimeout(() => {  
              uni.createSelectorQuery()  
        }, 1000)  
}

操作步骤:
mounted() {  
        console.log("mounted")  
        setTimeout(() => {  
              uni.createSelectorQuery()  
        }, 1000)  
}

预期结果:

可正常使用

实际结果:

报错 Uncaught TypeError: Cannot read property '$vm' of undefined

bug描述:

在组件mounted中使用uni.createSelectorQuery()报错 Uncaught TypeError: Cannot read property '$vm' of undefined

2021-04-25 15:10 负责人:无 分享
已邀请:
8***@qq.com

8***@qq.com (作者)

找到是怎么触发的了,App.vue中:
代码块1:

<template>  
    <view class="container">  
        <my-header></my-header>  
        <router-view class="router-container"></router-view>  
        <my-footer></my-footer>  
    </view>  
</template>

代码块2:

<template>  
    <view class="container">  
        <my-header></my-header>  
        <view class="page-container">  
            <router-view class="router-container"></router-view>  
        </view>  
        <my-footer></my-footer>  
    </view>  
</template>

使用代码块1正常,使用代码块2可以复现此问题,区别在于router-view标签是否被一层父元素包裹

该问题目前已经被锁定, 无法添加新回复