子:
onSubmit() {
this.$refs.ruleForm.validate(valid => {
if (valid) {
if (this.isEdit) {
updateEvent(this.id, this.form)
.then(response => {
if (response.data.success) {
this.$message.success(response.data.data)
this.$emit('refresh')
this.back()
}
})
.catch(error => {
console.log(error)
})
} else {
addEvent(this.form)
.then(response => {
if (response.data.success) {
this.$message.success(response.data.data)
this.$emit('refresh')
this.back()
}
})
.catch(error => {
console.log(error)
})
}
} else {
console.log('error submit!!')
return false
}
})
},
父:
refresh() {
this.getEventList()
},
this.$emit(‘refresh’),调用父组件刷新