在父组件中
<div id="app">
<com2 v-on:func="show"></com2>
</div>
com2就是引入父组件中的子组件
子组件模板
<template id="temp1">
<div>
<h1>这是一个子组件</h1>
<input type="button" @click="myclick">
</div>
</teamplate>
定义的字面量
var com2={
template:'temp1',
methods:{
this.$emit(func)
}
}
父组件的js代码
var vue=new Vue({
el:'#app',
data:{},
methods:{
show():{
console.log("调用了父组件的show方法")
}
},
components:{
com2
}
})