titleIndex 是变量 = 0
documentJson.title 是一个数组
<table>
<tr>{{titleIndex}}</tr> 显示 0
<tr>{{documentJson.title[titleIndex]}}</tr> 显示正常可以获取到 documentJson.title[0] 这个数组中的对象
<tr>{{documentJson.title[titleIndex].font_family}}</tr> 加上这行就出错,没明白原因
<tr>{{documentJson.title[0].font_family}}</tr> 把 变量直接改成 0 又不出错了,可以正常显示
</table>
在函数中也不出错
function fun(){
console.log('props.documentJson.title',props.documentJson.title[data.titleIndex].font_family)
}

vue3 dom中变量显示出错的 原因找不到
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- uliar 2022-04-25 13:40关注
具体报什么错,你在第二行试一试 {{titleIndex == 0?documentJson.title[titleIndex].font_family:''}}
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报