fix: 修复六爻结果页数组访问错误
- 添加数组类型检查 - 添加数组元素访问的安全检查 - 防止访问undefined数组的元素时报错
This commit is contained in:
1 parent
d4c54ecbe5
commit
b9ea8335d6
1 file changed
+9
-9
@@ -208,19 +208,19 @@ export default {
|
||||
return '-'
|
||||
},
|
||||
liuYaoData() {
|
||||
if (!this.result.benGuaLiuYaoName) return []
|
||||
if (!this.result.benGuaLiuYaoName || !Array.isArray(this.result.benGuaLiuYaoName)) return []
|
||||
|
||||
const data = []
|
||||
for (let i = 0; i < 6; i++) {
|
||||
data.push({
|
||||
name: this.result.benGuaLiuYaoName[i] || '-',
|
||||
liuShen: this.result.benGuaLiuYaoLiuShen[i] || '-',
|
||||
shiYing: this.result.benGuaLiuYaoShiYing[i] || '-',
|
||||
yaoXiang: this.result.benGuaLiuYaoAs[i] || '-',
|
||||
liuQin: this.result.benGuaLiuYaoLiuQin[i] || '-',
|
||||
ganZhi: this.result.benGuaLiuYaoGanZhi[i] || '-',
|
||||
wuXing: this.result.benGuaLiuYaoWuXing[i] || '-',
|
||||
naYin: this.result.benGuaLiuYaoNaYin[i] || '-'
|
||||
name: (this.result.benGuaLiuYaoName && this.result.benGuaLiuYaoName[i]) || '-',
|
||||
liuShen: (this.result.benGuaLiuYaoLiuShen && this.result.benGuaLiuYaoLiuShen[i]) || '-',
|
||||
shiYing: (this.result.benGuaLiuYaoShiYing && this.result.benGuaLiuYaoShiYing[i]) || '-',
|
||||
yaoXiang: (this.result.benGuaLiuYaoAs && this.result.benGuaLiuYaoAs[i]) || '-',
|
||||
liuQin: (this.result.benGuaLiuYaoLiuQin && this.result.benGuaLiuYaoLiuQin[i]) || '-',
|
||||
ganZhi: (this.result.benGuaLiuYaoGanZhi && this.result.benGuaLiuYaoGanZhi[i]) || '-',
|
||||
wuXing: (this.result.benGuaLiuYaoWuXing && this.result.benGuaLiuYaoWuXing[i]) || '-',
|
||||
naYin: (this.result.benGuaLiuYaoNaYin && this.result.benGuaLiuYaoNaYin[i]) || '-'
|
||||
})
|
||||
}
|
||||
return data.reverse()
|
||||
|
||||
Reference in new issue
Block a user