form 表单不提交时怎么把表单数据抛出到父组件?
onChange(e) { this.$nextTick(() => { this.form.validateFields((err, values) => { if (!err) { values = this.valuesTransform(values) console.log(values) this.$emit('changeCallBack', values) } }) }) },
表单项监听每一次的change事件。然后抛出。
不用 this.$nextTick (回调函数),则每次抛出的数据都是当前change 前一次的数据
<component :is="item.componentx" :key="index" :name="item.name" :type="item.type" :format="item.format" :show-time="item.showTime" v-decorator="[ item.name, { initialValue: initialValueHandle(item), rules: rule && item.rules }, ]" @change="onChange" style=" 100%" > <a-icon v-if="item.after" slot="addonAfter" type="search" /> </component>