vue组件中的一个计算属性code,依赖另一个计算属性projectPath(该属性只有数组或者undefined两种值),但是在code的计算函数中调用map,却报
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
},
报错:
自己坑了自己半小时。在其他地方写了一个错误,导致vue不会自动更新,这里应该是旧的代码有问题,但是改正后没有更新,导致代码和报错对不上。