Chuxy_Once
Chuxy_Once
  • 发布:2021-07-27 12:27
  • 更新:2021-07-27 12:27
  • 阅读:456

【报Bug】三级取值问题

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 3.1.22

手机系统: Android

手机系统版本号: Android 10

手机厂商: 小米

手机机型: Redmi K30

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<template>  
                <!-- <view class="title u-line-1 u-m-t-20">承 租 人:{{ lesseeDto.name || '' }}</view>  
                <view class="title u-line-1 u-m-t-20">联系方式:{{ lesseeDto.telPhone || '' }}</view> -->  
                <view class="title u-m-t-20">承 租 人:{{ contracdeatil.lesseeDto.name }}</view>  
                <view class="title u-line-1 u-m-t-20">联系方式:{{ contracdeatil.lesseeDto.telPhone }}</view>  

</template>  

<script>  
import ajax from '@/utils/request.js';  
export default {  
    data() {  
        return {  
            contractId: '',  
            contracdeatil: [],  
            lesseeDto: {},  
        };  
    },  
    onLoad: function(option) {  
        this.contractId = option.id;  
        this.getcontractinfo();  
    },  
    methods: {  
        getcontractinfo() {  
            const _this = this;  
            ajax.get({  
                url: 'zfappcontract/getcontractinfo',  
                data: {  
                    contractId: _this.contractId  
                },  
                success: function(res) {  
                    _this.contracdeatil = res;  
                    _this.lesseeDto = _this.contracdeatil.lesseeDto;  
                }  
            });  
        }  
    }  
};  
</script>  

<style lang="scss" scoped>  
.left {  
    display: flex;  
    align-items: center;  
}  
</style>

操作步骤:

三级取值

<view class="title u-m-t-20">承&ensp;租&ensp;人:{{ contracdeatil.lesseeDto.name }}</view>  
<view class="title u-line-1 u-m-t-20">联系方式:{{ contracdeatil.lesseeDto.telPhone }}</view>

预期结果:

二级取值无问题

<view class="title u-line-1 u-m-t-20">承&ensp;租&ensp;人:{{ lesseeDto.name || '' }}</view>  
<view class="title u-line-1 u-m-t-20">联系方式:{{ lesseeDto.telPhone || '' }}</view>

实际结果:

如图一

bug描述:

<view class="title u-m-t-20">承&ensp;租&ensp;人:{{ contracdeatil.lesseeDto.name }}</view>
三级取值报错: [Vue warn]: Error in render: "TypeError: Cannot read property 'name' of undefined"
页面·数据实际可以取出,但页面uView组件全部不可用

调整为二级取值可解决 <view class="title u-line-1 u-m-t-20">承&ensp;租&ensp;人:{{ lesseeDto.name || '' }}</view>

报错详情:
12:24:58.099 [Vue warn]: Error in render: "TypeError: Cannot read property 'name' of undefined"
12:24:58.159 (found at pages/contract/contractdeatil.vue:1)
12:24:58.190 TypeError: Cannot read property 'name' of undefined
12:24:58.221 cid unmatched [object Object] at view.umd.min.js:1
12:24:58.286 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:58.286 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
12:24:58.314 cid unmatched [object Object] at view.umd.min.js:1
12:24:58.346 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:58.397 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
12:24:58.419 cid unmatched [object Object] at view.umd.min.js:1
12:24:58.442 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:58.486 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
12:24:58.509 cid unmatched [object Object] at view.umd.min.js:1
12:24:58.532 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:58.573 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
12:24:58.595 cid unmatched [object Object] at view.umd.min.js:1
12:24:58.636 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:58.656 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
12:24:58.700 cid unmatched [object Object] at view.umd.min.js:1
12:24:58.719 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:58.759 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
12:24:58.781 cid unmatched [object Object] at view.umd.min.js:1
12:24:58.820 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:58.839 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
12:24:58.878 cid unmatched [object Object] at view.umd.min.js:1
12:24:58.913 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:58.929 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
12:24:58.971 cid unmatched [object Object] at view.umd.min.js:1
12:24:58.997 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:59.023 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
12:24:59.053 cid unmatched [object Object] at view.umd.min.js:1
12:24:59.096 TypeError: Invalid attempt to destructure non-iterable instance.
12:24:59.116 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1

2021-07-27 12:27 负责人:无 分享
已邀请:

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