2***@qq.com
2***@qq.com
  • 发布:2023-06-02 17:50
  • 更新:2023-06-02 17:58
  • 阅读:255

【报Bug】自定义组件中data的数据没有展示出来

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

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

HBuilderX类型: 正式

HBuilderX版本号: 3.8.4

手机系统: Android

手机系统版本号: Android 13

手机厂商: 小米

手机机型:

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

<template>
<view class="custom">
<view class="tab-bar bar-container">
<view v-for="(item, index) in list1" :key="index">{{item}}</view>

    </view>  
</view>  

</template>

<script>
import { mapState, mapMutations } from 'vuex';
export default {
name: "customTabBar",
data() {
return {
cStyle: "color: #999999;font-weight: 400;",
selectedStyle: "color: #2B2B2B;font-weight: 500;",

            list1: ["ces", "ces1", "ces2"],  
        };  
    },  
    computed: {  
        ...mapState({  
            selected: state => state.selected,  
        }),  
    },  

    watch: {  
    },  
    methods: {  
        ...mapMutations(['setSelected']),  
        switchTab(path, index) {  
            const url = path  
            this.setSelected(index)  
            uni.reLaunch({  
                url  
            })  
        },  
    }  
}  

</script>

操作步骤:

使用时v-for失败,而且单独展示list1为undefined

预期结果:

展示所有的list

实际结果:

没有出现

bug描述:

使用自定义组件时data的数据在代码中显示undefined

2023-06-02 17:50 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com (作者) - 一起开始新世界

<template>
<view class="custom">
<view class="tab-bar bar-container">
<view v-for="(item, index) in list1" :key="index">{{item}}</view>

    </view>  
</view>  

</template>

<script>
import { mapState, mapMutations } from 'vuex';
export default {
name: "customTabBar",
data() {
return {
cStyle: "color: #999999;font-weight: 400;",
selectedStyle: "color: #2B2B2B;font-weight: 500;",

            list1: ["ces", "ces1", "ces2"],  
        };  
    },  
    computed: {  
        ...mapState({  
            selected: state => state.selected,  
        }),  
    },  

    watch: {  
    },  
    methods: {  
        ...mapMutations(['setSelected']),  
        switchTab(path, index) {  
            const url = path  
            this.setSelected(index)  
            uni.reLaunch({  
                url  
            })  
        },  
    }  
}  

</script>

2***@qq.com

2***@qq.com (作者) - 一起开始新世界

已解决

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