-
<div id= "root" > -
<child @click= "handleClick" ></child> -
</div> -
<script> -
Vue.component('child',{ -
template: '<div @click= "handleChildClick" >child</div>', -
methods: { -
handleChildClick: function () { -
this .$emit('click') -
} -
} -
}) -
var vm = new Vue({ -
el: '#root', -
methods: { -
handleClick: function () { -
Alert ('handleClick method ') -
} -
} -
}) -
</script>
-
<div id= "root" > -
<child @click. native = "handleClick" ></child> -
</div> -
<script> -
Vue.component('child',{ -
template: '<div>child</div>' -
}) -
var vm = new Vue({ -
el: '#root', -
methods: { -
handleClick: function () { -
Alert ('handleClick method ') -
} -
} -
}) -
</script>