标签:lang routes 路由 pat script detail out ted temp
this.$router.push(‘/course‘);
this.$router.push({name: course});
this.$router.go(-1);
this.$router.go(1);
<router-link to="/course">课程页</router-link>
<router-link :to="{name: ‘course‘}">课程页</router-link>
routes: [
// ...
{
path: ‘/course/:id/detail‘,
name: ‘course-detail‘,
component: CourseDetail
},
]
<template>
<!-- 标签跳转 -->
<router-link :to="`/course/${course.id}/detail`">{{ course.name }}</router-link>
</template>
<script>
// ...
goDetail() {
// 逻辑跳转
this.$router.push(`/course/${this.course.id}/detail`);
}
</script>
created() {
let id = this.$route.params.id;
}
routes: [
// ...
{
path: ‘/course/detail‘,
name: ‘course-detail‘,
component: CourseDetail
},
]
<template>
<!-- 标签跳转 -->
<router-link :to="{
name: ‘course-detail‘,
query: {id: course.id}
}">{{ course.name }}</router-link>
</template>
<script>
// ...
goDetail() {
// 逻辑跳转
this.$router.push({
name: ‘course-detail‘,
query: {
id: this.course.id
}
});
}
</script>
created() {
let id = this.$route.query.id;
}
标签:lang routes 路由 pat script detail out ted temp
原文地址:https://www.cnblogs.com/Sunbreaker/p/11656133.html