父子组件同时更新(三种方法) VUE

01: this.$emit(‘自定义事件’,val)

<child-one :ms="a" @devicehandel="emithandel"></child-one>

<button @click='emithandel'>按钮</button>

methods: {
      emithandel() {
          this.$emit('devicehandel', '新one')
      }
}

02: v-model => ‘input’
this.$emit( ‘input’ ,val)

<child-two v-model="b"></child-two>

<button @click='emithandel'>按钮</button>

methods: {
      emithandel() {
          this.$emit('input', '新two')
      }
}

03: sync => ‘update:属性’
this.$emit( ‘update:ms’ , val )

<child-thr :ms.sync="c"></child-thr>

<button @click='emithandel'>按钮</button>

methods: {
      emithandel() {
         this.$emit('update:ms', '新thr')
      }
}

版权声明:本文为qq_25919495原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。