【发布时间】:2017-10-14 13:50:01
【问题描述】:
我正在构建一个步骤表单,我想执行验证并从我的子组件中获取数据。
所以我有一个步骤表格,我分为容器(父)和步骤 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>
如何在子组件中执行函数并从父组件中获取数据。
父结构更新
<stepper>
<v-stepper-content step="1">
<child-1></child-1>
<button @click.native="gotonextStep">Continue</v-btn>
</v-stepper-content>
...other stepper steps
</stepper>
【问题讨论】:
标签: javascript vue.js vuejs2 vue-component