父組件table的數據
columns: [
{
type: 'expand',
width: 50,
render: (h, params) => {
this.expandList = params.row.children ? params.row.children : []
return h(expandRow, {
props: {
row: this.expandList,
departid: params.row.id,
departname: params.row.name,
departIndex: params.index
},
on: {
'fatherMethod': (val) => { //當子組件數據變動時,調用父組件的函數getData
this.getData(val)
}
}
})
}
}]
子組件
handleSubmit () {
var data = {}
SetGepart(data).then(res => {
if (res.data.errno == 0) {
this.$emit('fatherMethod', this.departIndex) //調用父組件的函數
this.$Message.success('編輯成功')
} else {
this.$Message.error(res.data.message)
}
}).catch(err => {
console.log(err)
})
},