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)
}
具体报什么错,你在第二行试一试 {{titleIndex == 0?documentJson.title[titleIndex].font_family:''}}
<tr>{{documentJson.title[titleIndex]?.font_family || '-'}}</tr>
titleIndex 是steup的返回值吗?