小谢第11问:vue中,子组件获取的值怎么传给父组件

代码中,Helloword是子组件

<template>
  <div class="index">
    <Header></Header>
    <HelloWorld></HelloWorld>
    <button @click="goPro">跳转</button>
  </div>
</template>
mounted(){
 console.log(this.$children)
}

用ref绑定子组件,在父组件中通过$refs取对应的值或者方法

<HelloWorld ref="hello"></HelloWorld>
this.$refs.hello.属性
this.$refs.hello.方法

 

posted @ 2020-06-02 14:33  优雅的小谢  阅读(462)  评论(0编辑  收藏  举报
Live2D