- 首先不能不说就是他的
$emit
方法,下面以子组件向父组件传值为例。。。
<!DOCTYPE html>
<html>
<head>
<title>vueReivew05</title>
<script src='vue2.js'></script>
<script src='vue-router3.js'></script>
<script type="text/javascript">
window.onload=function(){
//定义全局组件
Vue.component('hello',{
template:
`<div>
<h1>hello</h1>
<button @click='send'>click me</button>
</div>`,
data(){
return {
msg:'hello'
}
},
methods:{
send(){
this.$emit('func',this.msg);
}
}
});
var vm=new