vue組件中的一個(gè)計(jì)算屬性code,依賴另一個(gè)計(jì)算屬性projectPath(該屬性只有數(shù)組或者undefined兩種值),但是在code的計(jì)算函數(shù)中調(diào)用map,卻報(bào)TypeError: this.projectPath.map(...) is not a function這是什么道理???代碼: code () { if (this.projectPath) { console.log(typeof this.projectPath.map) let list = this.projectPath.map(item => item.nodeCode) return list.join('_')
} return undefined
},報(bào)錯(cuò):
2 回答

慕森卡
TA貢獻(xiàn)1806條經(jīng)驗(yàn) 獲得超8個(gè)贊
你的報(bào)錯(cuò)里說(shuō)的是 pathList
而你打印輸出的是 projectPath
。
你應(yīng)該看 pathList
是不是 null
或者 undefined
了。
添加回答
舉報(bào)
0/150
提交
取消