1、两种方式
- 通过判断实体属性是否存在id
- 判断请求路径是否存在id
2、获取请求路径id的方式
this.$route.params.id
一般把添加和更新的函数写为这种形式
saveOrUpdate() {
//判断路由是否有路由参数
if (this.$route.params && this.$route.params.id) {
this.updateCourseInfo();
} else {
this.saveCourseInfo();
}
},