去掉this.$set语法(语法报错),在3.0已废弃,用 proxy 实现双向绑定不会出现不更新的问题

pull/283/head
lss 2021-05-12 17:41:36 +08:00
parent 4dd1b4aae6
commit 8c1b5ce574
1 changed files with 121 additions and 118 deletions

View File

@ -110,14 +110,14 @@
</template>
<script>
import { fetchData } from "../api/index";
import { fetchData } from '../api/index';
export default {
name: "basetable",
name: 'basetable',
data() {
return {
query: {
address: "",
name: "",
address: '',
name: '',
pageIndex: 1,
pageSize: 10
},
@ -145,17 +145,18 @@ export default {
},
//
handleSearch() {
this.$set(this.query, "pageIndex", 1);
// this.$set(this.query, "pageIndex", 1); // this.$set3.0 proxy
this.query.pageIndex = 1;
this.getData();
},
//
handleDelete(index) {
//
this.$confirm("确定要删除吗?", "提示", {
type: "warning"
this.$confirm('确定要删除吗?', '提示', {
type: 'warning'
})
.then(() => {
this.$message.success("删除成功");
this.$message.success('删除成功');
this.tableData.splice(index, 1);
})
.catch(() => {});
@ -166,10 +167,10 @@ export default {
},
delAllSelection() {
const length = this.multipleSelection.length;
let str = "";
let str = '';
this.delList = this.delList.concat(this.multipleSelection);
for (let i = 0; i < length; i++) {
str += this.multipleSelection[i].name + " ";
str += this.multipleSelection[i].name + ' ';
}
this.$message.error(`删除了${str}`);
this.multipleSelection = [];
@ -184,11 +185,13 @@ export default {
saveEdit() {
this.editVisible = false;
this.$message.success(`修改第 ${this.idx + 1} 行成功`);
this.$set(this.tableData, this.idx, this.form);
// this.$set(this.tableData, this.idx, this.form);
this.tableData[this.idx] = this.form;
},
//
handlePageChange(val) {
this.$set(this.query, "pageIndex", val);
// this.$set(this.query, "pageIndex", val);
this.query.pageIndex = val;
this.getData();
}
}