我正在構建一個步驟表單,我想從我的子項目組件執行驗證和提取數據。Vue js從父項執行子項並獲取數據
所以我有一個步驟的形式,其香港專業教育學院分離成容器(父)和步驟1(子)
孩子有表單數據
在子我有
<template>
thre is the form fiedls
</template>
<script>
data:()=>({
orderform:{
first_name:'',
lastname:''
}
}),
methods:{
submitOrder(){
this.$validator.validateAll()
.then(
(res)=>{
if(res){
//pass this.orderform to parent component
}
}
)
}
}
現在在家長
<script>
methods:{
gotonextStep(){
//here execute submitOrder function in the child mcomponent
//am stuck
//also retrieve order form data here.
}
}
</script>
如何執行子組件中的函數並從父組件中檢索數據。
UPDATE ON母體結構
<stepper>
<v-stepper-content step="1">
<child-1></child-1>
<button @click.native="gotonextStep">Continue</v-btn>
</v-stepper-content>
...other stepper steps
</stepper>
感謝您的解決方案令人驚歎並且直截了當。 –