微信扫一扫看面试题

关注面试题库

[Vue warn]: Error in callback for watcher “fileList“: “TypeError: Cannot create property ‘uid‘ on st

[Vue warn]: Error in callback for watcher "fileList": "TypeError: Cannot create property 'uid' on string

报错原因:
TypeError: Cannot create property ‘xxx’ on string ‘xxxx’,此类错误是赋值的类型错误
如以上示例错误,在使用ElementUI的upload组件时,把字符串列表赋值给了
fileList
,而
fileList
需求的是对象的列表



示例错误代码:

pictureList = ['url1', 'url2'];
this.fileList = pictureList;



示例正确代码:

pictureList = ['url1', 'url2'];
this.fileList = pictureList.map(item => {
       return {
         name: item,
         url: item
       }
});

 Tips:【小程序云开发】中高级前端面试题库(1000+)(小程序中联系我哟)。
---------- 创作不易,感谢大家,请多多支持!

posted @ 2022-07-23 10:02  web前端面试小助手  阅读(664)  评论(0)    收藏  举报