1、子组件

<template>
    <div>
              <button v-on:click="sendMsg">向父组件传参</button> 
    </div>
</template>
 
<script>
export default {
  name: 'parent',
  props: ['list'],
  methods: {
    sendMsg: function () {
      this.$emit('childInfo', '子组件的参数内容'); //第一个参数是父组件中绑定的自定义回调方法,第二个参数为传递的参数
    }
  }
};
</script>
 

2、父组件(需要在引用的子组件中完成)

<file v-on:childInfo="get"   v-bind:Id="fileId"></file>
 methods: {
     get(info){
        debugger;
        this.fileInfo=info;
      },
  }

 

posted on 2018-11-01 11:38  天涯浪子1955  阅读(376)  评论(0编辑  收藏  举报