父组件代码:

<template lang="pug">
  div
    p this is father
    child(v-model="data")
</template>
<script>
  import child from "./childrenS.vue";
  export default{
    data(){
      return {
        data: [1, 2, 3]
      }
    },
    components: {
      child
    },
    watch: {
      data(n, o){
        console.log(n,o)
      }
    }
  }
</script>

  子组件代码:

<template lang="pug">
  div this is child
</template>
<script>
  export default{
      created(){
          this.$emit("input",[4,5,6])
      }
  }
</script>

  效果如下:

vue2.0中子组件通过v-modal改变父组件中的值

 

相关文章:

  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-01-11
  • 2022-01-26
  • 2021-12-15
  • 2021-09-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案