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