XBoot Vue学习笔记
- post请求
this.postRequest('/stageTemplate/getFrontStages',{project_id:v}).then(res =>{
if(res.success === true){
this.$Message.success('获取前置阶段成果')
}
})
- 页面跳转
// 记录返回路由
let query = { id: v.id, backRoute: this.$route.name };
this.$router.push({
// 该路由已在/router/router.js中定义好 携带id参数
name: "edit",
query: query
});
init() {
this.handleReset();
this.form.id = this.$route.query.id;
this.backRoute = this.$route.query.backRoute;
this.getData();
},
// 关闭当前页面
closeCurrentPage() {
this.$store.commit("removeTag", "edit");
localStorage.pageOpenedList = JSON.stringify(
this.$store.state.app.pageOpenedList
);
this.$router.push({
name: this.backRoute
});
}
watch: {
// 监听路由变化通过id获取数据
$route(to, from) {
if (to.name === "edit") {
this.handleReset();
this.form.id = this.$route.query.id;
this.getData();
}
}
},
mounted() {
this.init();
}
3.获取字典类型数据
// 获取请假类型字典数据
getDictDataByType("leave_type").then(res => {
if (res.success) {
this.dictType = res.result;
}
});
```
4.
{
title: "建筑类型",
key: "architectureType",
minWidth: 120,
sortable: false,
align: "center",
render: (h, params) => {
let re = "";
this.allHouseTypes.forEach(e => {
if (e.id == params.row.architectureType) {
re = e.title;
}
});
return h("div", re);
}
},
网友评论