使用watch监听props传来的值,监听到变化后,调用后续方法
props: {
fatRow: {
type: Object
},
},
watch: {
fatRow (val) {
this.loadData()
}
},
methods: {
loadData (arg) {
console.log(this.fatRow.did);
if (!this.url.list) {
this.$message.error("请设置url.list属性!")
return
}
if (arg === 1) {
this.ipagination.current = 1;
}
var params = {
did: this.fatRow.did
};
this.loading = true;
getAction(this.url.list, params).then((res) => {
if (res.success) {
this.dataSource = res.result.records || res.result;
if (res.result.total) {
this.ipagination.total = res.result.total;
} else {
this.ipagination.total = 0;
}
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
}