2***@qq.com
2***@qq.com
  • 发布:2023-10-12 14:23
  • 更新:2024-06-04 15:30
  • 阅读:324

【报Bug】使用uni-table组件this.$parent.$options.name 报错undefined

分类:uni-app

产品分类: uniapp/小程序/阿里

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 3.8.12

第三方开发者工具版本号: 3.7.13

基础库版本号: "name": "minnesota", "version": "1.0.0",

项目创建方式: HBuilderX

示例代码:

<uni-collapse>
<uni-collapse-item v-for='(prescription,index) in bill.prescriptions' :key="index" :title="prescription.dpName">
<!-- <text slot="title">{{prescription.dpName}}</text> -->
<template v-slot:title>
<view class="uni-collapse-itemtitle-box">
<view class="uni-collapse-item
title-text">
<view style="overflow: hidden;" :class="{active: index === activeIndex}">
<text v-show="!!showPayBtn" @click.native.stop="chooseBill(index, prescription)" >
<uni-icons type="checkbox-filled" size="24" ></uni-icons>
</text>
<text v-show="!!showPayBtn" style="margin-left:15px">
{{ prescription.priority }}
</text>
<text>
{{prescription.dpName}}
</text>
</view>
</view>
</view>
</template>
<view class="content">
<view class="uni-container">
<uni-table ref="table" :loading="loading" >
<uni-tr >
<uni-th align="center">名称</uni-th>
<uni-th align="center">规格</uni-th>
<uni-th align="center">数量</uni-th>
<uni-th align="center">金额</uni-th>
</uni-tr>
<uni-tr v-for='(bill,i) in items[index]' :key="i">
<uni-td align="center">{{ bill.itemName }}</uni-td>
<uni-td align="center">
{{ bill.leastUnit }}
</uni-td align="center">
<uni-td align="center">
{{ bill.leastNumber }}
</uni-td>
<uni-td align="center">
¥{{ bill.itemAmount|currency }}
</uni-td>
</uni-tr>
</uni-table>
</view>
</view>
</uni-collapse-item>
</uni-collapse>

操作步骤:

getTable(name) {
let parent = this.$parent
let parentName = parent.$options.name
console.log('this:',this)

        console.log('parent:', this.$parent)  
        console.log('parentName:', parent.$options.name)  
        while (parentName !== name) {  
            parent = parent.$parent  

            if (!parent) return false  
            parentName = parent.$options.name  
        }  
        return parent  
    }

预期结果:

getTable(name) {
let parent = this.$parent
let parentName = parent.$options.name
console.log('this:',this)

        console.log('parent:', this.$parent)  
        console.log('parentName:', parent.$options.name)  
        while (parentName !== name) {  
            parent = parent.$parent  

            if (!parent) return false  
            parentName = parent.$options.name  
        }  
        return parent  
    }

实际结果:

this.$parent.$options.name不存在

bug描述:

使用uni-collapse +uni-table组件因为无法找到this.$parent.$options.name导致报错

2023-10-12 14:23 负责人:无 分享
已邀请:
辉笑流

辉笑流

我也遇到这个问题了,同问。我的是vue3版本

要回复问题请先登录注册