关于前端:TypeError-Cannot-read-properties-of-undefined-reading

3次阅读

共计 314 个字符,预计需要花费 1 分钟才能阅读完成。

在查看本文前,心愿各位能够好好看看这一篇文章:该报错的单个组件解决方案

在网上查找时看到的最好解答,举荐具体看看

多组件应用以下计划:

因为多组件时,在父组件应用 status,status 的状态无奈复用,所以将 status 放到子组件中

子组件 HTML 局部:

<template>
    <div v-if="status">
          {{index[0].text }}
    </div>
</template>

子组件 JavaScript 局部:

export default {props: ['index'],
    data() {
        return {status: false,}
    },
    mounted() {this.status = true;},
}

这样做是为了让每个子组件在获取到数据后再渲染

正文完
 0