父组件内容:

<template>
    <div>
        <info-wnd ref="infoWnd" @parentClick="wndClick"></info-wnd>
  </div>

</template>
<script>
    import infoWnd from './info-wnd';
    export default {
        data() {
            return {
            }
        },
        components: { infoWnd },
        methods: {
            wndClick() {
                   console.log('这是父组件的方法');
             }
         } 
    } 
</script>   

子组件Info-wnd.vue组件内容:

<template>
    <div @click="divClick">
        <span>这是子组件</span>
    </div>
</template>
<script>
    export default {
        data() {
            return {
            }
        },
        methods: {
            divClick() {
                this.$emit('parentClick');    //调用父组件的方法
            }
        }
    }
</script>

 

posted on 2018-10-22 14:44  minoz  阅读(290)  评论(0编辑  收藏  举报