楼主遇到的问题是表单引擎
为undefined
,是因为表单子组件还没渲染好的缘故。
方案一
加上 this.$nextTick()
就好了
this.$nextTick(() => {
let myEnForm = this.$refs.myComp // 获取表单引擎组件引用
//...
this.$refs.oneForm.resetFields()
this.$refs.threeForm.resetFields()
})
方案二
如果方案一依然不能解决的话,可以试试定时器setTimeOut()
。
setTimeOut(() => {
let myEnForm = this.$refs.myComp // 获取表单引擎组件引用
// ...
this.$refs.oneForm.resetFields()
this.$refs.threeForm.resetFields()
}, 10)