Skip to content

fix(upload-imgs):修复 upload-imgs 组件初始化未传 id 字段进行操作报错的 bug #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

yyywang
Copy link
Contributor

@yyywang yyywang commented Mar 25, 2020

upload 图像上传组件初始化数据未传id字段,点击组件的“更换图片”时报错

  • 初始化数据
imgInitData: [{
        display:'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100'
}]
  • 报错信息
index.vue?6ced:895 TypeError: Cannot read property 'display' of undefined
    at VueComponent.setImgInfo (index.vue?6ced:911)
    at VueComponent._callee5$ (index.vue?6ced:882)
    at tryCatch (runtime.js?96cf:45)
    at Generator.invoke [as _invoke] (runtime.js?96cf:271)
    at Generator.prototype.<computed> [as next] (runtime.js?96cf:97)
    at asyncGeneratorStep (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/base/upload-imgs/index.vue?vue&type=script&lang=js&:7)
    at _next (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/base/upload-imgs/index.vue?vue&type=script&lang=js&:9)

经排查,初始化数据中必须传入id字段,但官方文档中说id为可选初始化字段,否则报以上错误。在创建已存在数据时设置默认 id 即可修复上述 bug

@quanquan2100 quanquan2100 merged commit ff03afe into TaleLin:master Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants