如题,页面能正常展示,但是有个 e is undefined 报错
<div class="c-flex-1" v-if="userInfo.customerTag.length">
<el-tag
v-for="(item, index) in userInfo.customerTag"
:key="index"
size="small"
class="c-mb5"
>
{{ item.name }}
</el-tag>
</div>
往往是类似代码中的写法,只在data中定义了userInfo,但是使用的时候却是userInfo.customerTag
解决方法:
1.详细在data中定义到userInfo.customerTag,给个默认值,不过为空对象/数组的,有时直接渲染还是会报错,因为没下标
userInfo: {
customerTag: []
},
2.在html上做一下v-if判断,等数据存在了再进行渲染