店小二丶
店小二丶
  • 发布:2023-04-04 17:35
  • 更新:2023-04-11 12:46
  • 阅读:514

【报Bug】picker-view 使用v-if等于false 时,APP端控制台报错

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Win11

HBuilderX类型: 正式

HBuilderX版本号: 3.7.9

手机系统: Android

手机系统版本号: Android 12

手机厂商: 小米

手机机型: 小米11pro

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<template> <view> <view class="uni-padding-wrap"> <view class="uni-title">日期:{{ year }}年{{ month }}月{{ day }}日</view> </view> <button hover-class="button-hover" @click="visible = !visible">点击</button> <picker-view v-if="visible" indicator-style="indicatorStyle" value="value" class="picker-view"
@change="bindChange"
>
<picker-view-column>
<view v-for="(item, index) in years" :key="index" class="item"
>{{ item }}年</view
>
</picker-view-column>
<picker-view-column>
<view v-for="(item, index) in months" :key="index" class="item"
>{{ item }}月</view
>
</picker-view-column>
<picker-view-column>
<view v-for="(item, index) in days" :key="index" class="item"
>{{ item }}日</view
>
</picker-view-column>
</picker-view>
</view>
</template>
<script>
export default {
data: function () {
const date = new Date();
const years = [];
const year = date.getFullYear();
const months = [];
const month = date.getMonth() + 1;
const days = [];
const day = date.getDate();
for (let i = 1990; i <= date.getFullYear(); i++) {
years.push(i);
}
for (let i = 1; i <= 12; i++) {
months.push(i);
}
for (let i = 1; i <= 31; i++) {
days.push(i);
}
return {
title: "picker-view",
years,
year,
months,
month,
days,
day,
value: [9999, month - 1, day - 1],
visible: true,
indicatorStyle: height: 50px;,
};
},
methods: {
bindChange: function (e) {
const val = e.detail.value;
this.year = this.years[val[0]];
this.month = this.months[val[1]];
this.day = this.days[val[2]];
},
},
};
</script>
<style>
.picker-view {
width: 750rpx;
height: 600rpx;
margin-top: 20rpx;
}
.item {
line-height: 100rpx;
text-align: center;
}
</style>

操作步骤:

切换visible 值

预期结果:

弹出隐藏picker-view 不报错

实际结果:

控制台报错并且正式环境会通过uni统计统计JS错误

bug描述:


<picker-view  
      v-if="visible"  
      :indicator-style="indicatorStyle"  
      :value="value"  
      class="picker-view"  
      @change="bindChange"  
    >  
      <picker-view-column>  
        <view v-for="(item, index) in years" :key="index" class="item"  
          >{{ item }}年</view  
        >  
      </picker-view-column>  
      <picker-view-column>  
        <view v-for="(item, index) in months" :key="index" class="item"  
          >{{ item }}月</view  
        >  
      </picker-view-column>  
      <picker-view-column>  
        <view v-for="(item, index) in days" :key="index" class="item"  
          >{{ item }}日</view  
        >  
      </picker-view-column>  
    </picker-view>  

切换visible的值,控制台会报错,Uncaught TypeError: Cannot read properties of null (reading '$el') at uni-app-view.umd.js:1

使用的就是官方的picker-view例子

2023-04-04 17:35 负责人:YUANRJ 分享
已邀请:

最佳回复

DCloud

DCloud

HBuilderX 3.7.13.20230411-alpha 已修复。

YUANRJ

YUANRJ

感谢反馈,后续修复,已加分。

YUANRJ

YUANRJ

临时解决方案:替换附件文件到以下目录,然后重新编译。
HBuilderX根目录/plugins/uniapp-cli-vite/node_modules/@dcloudio/uni-app-plus/dist

  • 店小二丶 (作者)

    我想问一下 这个云打包解决了么,他报错会不停的被uni统计记录

    2023-04-11 10:33

  • YUANRJ

    回复 店小二丶: 升级下版本

    2023-04-11 13:10

星拾夜暝

星拾夜暝

https://ask.dcloud.net.cn/people/DCloud_HB_WDL ,找这个人,是官方的人,一直@@就行 DCloud_UNI_YRJ

  • DCloud_UNI_GSQ

    HBuilderX编辑器相关的反馈可以找他,其他uni-app相关的Bug反馈可以邀请我处理,其他业务相关问题也可以邀请其他活跃用户

    2023-04-07 17:58

要回复问题请先登录注册