美文网首页
vue调用组件的内部方法

vue调用组件的内部方法

作者: flyjar | 来源:发表于2020-09-09 15:43 被阅读0次

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>

相关文章

网友评论

      本文标题:vue调用组件的内部方法

      本文链接:https://www.haomeiwen.com/subject/efweektx.html