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

父组件代码:

<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>

  效果如下:

 

posted @ 2017-12-26 15:55  明明一颗大白菜  阅读(4973)  评论(0编辑  收藏  举报
<-- -->