1. 程式人生 > >[Vue warn]: Error in render: "TypeError: this.formData.subImages.split is not a function"

[Vue warn]: Error in render: "TypeError: this.formData.subImages.split is not a function"

問題:

錯誤程式碼:

computed:{
//附圖輪播圖
subImgList(){
let imgArray = this.formData.subImages.split(',');
imgArray.map(n => {
this.subImg.push({
name:'sub-img',
url:n
      })
    })
return this.subImg;
},
},

解決辦法:

let imgArray = (this.formData.subImages || "").split(',');
參考文章:點選開啟連結