父组件中代码:
html代码:
<el-dialog :visible.sync="isDeliveryDialogShow" width="30%" :before-close="handleClearData">
<delivery ref="ref" :form="form" @isDeliveryDialogClose="isDeliveryDialogClose" ></delivery>
</el-dialog>
其中ref="ref" :before-close="handleClearData"
js代码:
handleClearData() {
console.log('-----')
this.$refs.ref.handleClearData()
}
子组件中代码:
js代码:
handleClearData() {
this.$refs['form'].resetFields();
this.express_order_image = '';
this.$emit('isDeliveryDialogClose')
console.log('111',this.express_order_image, this.form)
},
这样就能实现子组件提交时内容的清除