Vue实现子组件向父组件传值
开搞
1.父组件中引入子组件
import hello from './hello.vue'
2.父组件中申明子组件
components:{
hello
},
3.使用子组件,并接受传递过来的值
<hello ref="helloRef" @helloStr="getHelloStr" />
getHelloStr(data){
console.log('我接收到了值')
}
4.在子组件中需要向父组件传值处使用
this.$emit("helloStr",param);