Vue报错:TypeError: Cannot create property 'xxx' on string 'xxxx'
报错详情:[Vue warn]:Error in callback for immediate watcher "fileList":"TypeError: Cannot create property 'uid' on string 'string_url_1'"...示例如图:报错原因:TypeError: Cannot create property ‘xxx’ on ...
·
报错详情:
[Vue warn]:
Error in callback for immediate watcher "fileList":
"TypeError: Cannot create property 'uid' on string 'string_url_1'"
...
示例如图:
报错原因:
TypeError: Cannot create property ‘xxx’ on string ‘xxxx’,此类错误是赋值的类型错误,如以上示例错误,在使用ElementUI的upload组件时,把字符串列表赋值给了fileList
,而fileList
需求的是对象的列表。
示例错误代码:
pictureList = ['string_url_1', 'string_url_2'];
this.fileList = pictureList;
示例正确代码:
pictureList = ['string_url_1', 'string_url_2'];
this.fileList = pictureList.map(item => {
return {
name: item,
url: baseUrl + item
}
});
更多推荐
已为社区贡献1条内容
所有评论(0)