zhaobinglong / myBlog

https://zhaobinglong.github.io/myBlog/
MIT License
7 stars 0 forks source link

vue3开发过程中的常见错误 #150

Closed zhaobinglong closed 3 years ago

zhaobinglong commented 3 years ago

runtime-core.esm-bundler.js?5c40:38 [Vue warn]: Extraneous non-emits event listeners (itemChange) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.

export default {
  name: 'xxx',
  emits: ['itemChange'], // 在这里申明你要广播的事件
  props: {

  },
}
zhaobinglong commented 3 years ago

[Vue warn]: Property "xxxx" was accessed during render but is not defined on instance.

zhaobinglong commented 3 years ago

重复渲染多个组件,每个组件中都有回调函数,最终只触发最后一个回调函数

实际业务场景:在移动端H5场景中,自定义一个上传组件,重复渲染多次该组件,当app上传资源成功后,要调用组件的回调函数,结果每次都调用了最后一个组件的回调函数

zhaobinglong commented 3 years ago

[Vue warn]: Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.