嗨,我只是想看看是否存在{data.name}}。如果不存在,就不要显示这一点。
迭代:
<div v-if="conts.Titre || conts.keys(conts.Titre).length > 0" class="communes-contenu">
<div v-if="conts.Titre != ' '" class="communes-contenu">
<h3 v-if="conts.Titre">{{ conts.Titre }}</h3>但没什么..。只是一个“不能读取空”的属性'Titre‘
太棒了!
发布于 2018-07-13 10:44:01
"Cannot read property 'Titre' of null"意味着持有Titre的对象为空。
=> conts必须为空。
您可以在同一个v-if中添加对conts是否存在的额外检查,或者将其包装起来。
备选案文1:
<h3 v-if="conts && conts.Titre">{{ conts.Titre }}</h3>备选案文2:
<template v-if="conts">
<h3 v-if="conts.Titre">{{ conts.Titre }}</h3>
</template>https://stackoverflow.com/questions/51323007
复制相似问题