去掉this.$set语法(语法报错),在3.0已废弃,用 proxy 实现双向绑定不会出现不更新的问题
parent
4dd1b4aae6
commit
8c1b5ce574
|
@ -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.$set在3.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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue