<body> <div id="app"> <!-- 2.监听子组件发射的事件 然后再父组件处理事件 --> <cpn @itemclick="cpnClick"></cpn> </div> <template id="cpn"> <div> <button v-for="item in categories" @click="btnClick(item)"> {{ item.name }} </button> </div> </template> <script src='https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js'></script> <script> const cpn = { template: "#cpn", data() { return { categories: [{ id: 'aaa', name: "热门推荐" }, { id: 'bbb', name: "手机数码" }, { id: 'ccc', name: "家用电器" }, { id: 'ddd', name: "电脑办公" }, ] } }, methods: { btnClick(item) { // 1. 子传父 用发射事件 $emit("自定义事件名称",传递的参数) this.$emit("itemclick", item) } } } const app = new Vue({ el: '#app', data: { }, components: { cpn, }, methods: { cpnClick(item) { console.log(item); } } }) </script> </body>