Vue组件子传父 HTML attributes are case-insensitive and camelCased props...

  • 2021-08-03
  • 最新修改时间: 2021-08-04
  • web html css js 插件
  • 公开
简介Prop "dialogvisible" is passed to component <Anonymous>, but the declared prop name is "dialogVisible". Note that HTML attributes are case-insensitive and camelCased props need to use their kebab-case equivalents when using in-DOM templates. You sho

Prop "dialogvisible" is passed to component <Anonymous>, but the declared prop name is "dialogVisible". Note that HTML attributes are case-insensitive and camelCased props need to use their kebab-case equivalents when using in-DOM templates. You should probably use "dialog-visible" instead of "dialogVisible".


将驼峰dialogVisible转为小写dialogvisible 或者  dialog-visible

如:this.$emit('dialog-visible',false)


.sync的用法仔细阅读“.sync修饰符”。


父组件:

<login v-bind:dialogVisible.sync="dialogVisible"></login>

子组件:

props: ["dialogVisible"],
onSubmit: function() {
      this.$emit('update:dialogvisible', false)
}

即,this.$emit中的变量不能使用驼峰命名法!