‘
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>评论列表实现</title>
</head>
<body>
<div id="app">
    <com2 @subshow="show"></com2>
</div>
<template id="tmp1">
    <div>
        <h1>这是子组件</h1>
        <input type="button" value="按我" @click="myclick">
    </div>
</template>
<script src="./lib/vue-2.4.0.js"></script>
<script>
    var com2={
        template:'#tmp1',
        data() {
            return {
                sonmsg: { name: '小头儿子', age: 6 },
            }
        },
        methods:{
            myclick(){
                // this.$emit('parentShow')
                this.$emit('subshow',this.sonmsg)
            }
        }
    };
    // 创建 Vue 实例,得到 ViewModel
    var vm=new Vue({
        el:'#app',
        data:{},
        methods:{
            show(msg){
                console.log("这是父组件的方法");
                console.log(msg)
            }
        },
        components:{
            com2:com2
        }
    })
</script>
</body>
</html>