一.父组件关键代码:

<template>
  <div id="app">
    <h1>title</h1>
<Survey-form ref = "SurveyForm" ></Survey-form> <!--说明: 注册 ref 子主键 -->
</template>
<script>
import axios from 'axios'
 
import SurveyForm from './components/SurveyForm'  
import SelectForm from './components/SelectForm'
export default {
name: 'App',
components: {
SurveyForm,SelectForm           
},
methods:{
  
  selecty:function(v){
    
        //在父主键方法内,执行子组件方法:callApi
        vm.$refs.SurveyForm.callApi()
 
  
  }
</script>
 


二.子组件

略...

<script>

methods:{

                callApi:function () {

                    ...略...
                }
}
</script>                            

 

相关文章:

  • 2021-11-19
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-17
  • 2021-08-19
  • 2021-11-07
  • 2021-08-23
  • 2022-01-10
相关资源
相似解决方案