小谢第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.方法
    既然许愿了,就努力去实现
 
                     
                    
                 
                    
                
 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号