修复切换组件时,数据的设置数据不更新的问题

This commit is contained in:
aixianling
2024-02-28 15:08:09 +08:00
parent 8a1fa07e9b
commit 13b779ff3e
3 changed files with 40 additions and 47 deletions

View File

@@ -15,7 +15,6 @@ export default {
},
data() {
return {
records: [],
form: {}
}
},
@@ -44,7 +43,8 @@ export default {
})
}
},
columns: v => v.configs
columns: v => v.configs,
records: v => v.tableData.map(e => ({$cellEdit: true, ...e}))
},
methods: {
rowSave(form, done) {
@@ -74,16 +74,13 @@ export default {
})
}
},
created() {
this.records = this.tableData.map(e => ({$cellEdit: true, ...e}))
}
}
</script>
<template>
<section class="tableEditor">
<avue-crud :option="option" :data="records" @row-save="rowSave" @row-cancel="rowSave" @row-del="rowDel">
<template v-for="c in columns" :slot="`${c.prop}Header`" slot-scope="{column = {}}">
<template v-for="col in columns" :slot="`${col.prop}Header`" slot-scope="{column = {}}">
<el-input class="headerInput" v-model="column.label" clearable placeholder="请输入列名" @change="$emit('update:configs', columns)"/>
</template>
<template v-if="label" v-slot:menuLeft>