Vue页面
<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>
网友评论