一。路由跳转

  在vue中,路由条状有很多种。

  其中有点击事件触发的路由跳转:

this.$router.push('/course');

  和通过名字跳转的:

this.$router.push({name: course});

  对history操作的go语法,可以调节回退页面:

this.$router.go(-1);
this.$router.go(1);

  在router-link中,也有可以跳转路由的方法:

<router-link to="/course">课程页</router-link>

  跳转字典对象的:

<router-link :to="{name: 'course'}">课程页</router-link>

二。路由传参。

  如果需要传递参数给各个页面。反馈不同的页面,需要传毒有参路由:

  第一种。

  通过:id的有参参数传递给路由:

  router.js

routes: [
// ...
{
path: '/course/:id/detail',
name: 'course-detail',
component: CourseDetail
},
]

  跳转。vue

<template>
<router-link :to="`/course/${course.id}/detail`">{{ course.name }}</router-link>
</template>
<script>
// ...
goDetail() {
this.$router.push(`/course/${this.course.id}/detail`);
}
</script>

  接受vue:

created() {
let id = this.$route.params.id;
}

  第二种

  在push种有params传递参数,也可以通过query传递参数,这里通过router-link传递字典对象。

  router.js

routes: [
// ...
{
path: '/course/detail',
name: 'course-detail',
component: CourseDetail
},
]

  跳转。vue

<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>

  接受。vue

created() {
let id = this.$route.query.id;
}

day67_10_11的更多相关文章

随机推荐

  1. 【cf1272】F. Two Bracket Sequences

    传送门 题意: 给出\(s,t\)两个合法括号序列,现在找到一个长度最小的合法的序列\(p\),使得\(s,t\)都为其子序列. 思路: 考虑\(dp:dp[i][j][d]\)表示第一个串在\(i\ ...

  2. 在Windows系统中安装matplotlib,需要注意的问题

    matplotlib的下载地址:https://pypi.org/project/matplotlib/#files 以python3.6为例,适合的版本matplotlib-3.1.1-cp36-c ...

  3. Android 中的AlertDialog使用自定义布局

    Android使用指定的View开发弹窗功能 Android开发中进程会使用到我们的AlertDialog,但是比较可惜的是我们的Android原生的AlertDialog的效果又比较的简陋,这个时候 ...

  4. LVS 负载均衡——直接路由模式DR

    一.配置的网络拓扑结构图 二.配置lvs服务器 配置虚拟网卡地址(VIP地址) [root@localhost ~]# ifconfig eno16777728: 192.168.200.253 ne ...

  5. Codeforces Round #594 (Div. 1) D. Catowice City 图论

    D. Catowice City In the Catowice city next weekend the cat contest will be held. However, the jury m ...

  6. 微信公众号开发 ,redirect_uri域名还是与后台配置不一致

    测试账号地址: https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index https ...

  7. 解决centos下tomcat启动太慢 & JDBC连接oracle太慢的问题

    近期遇到一个非常奇怪的问题,也不知道改了什么,tomcat启动非常慢,以前几秒就启动好了,现在要30秒左右. 而且,通过jdbc连接oracle数据库也非常慢,以前建立一个连接只要几十毫秒,现在也要1 ...

  8. 安装 Java

    1.rpm下载地址 https://download.oracle.com/otn/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm?AuthParam=1570520 ...

  9. oracle多表关联update

    日常的开发中一般都是写的单表update语句,很少写多表关联的update. 不同于SQL Server,在Oracle中,update的多表连接更新和select的多表连接查询在使用的方法上存在较大 ...

  10. php捕获Fatal error错误与异常处理

    php中的错误和异常是两个不同的概念. 错误:是因为脚本的问题,比如少写了分号,调用未定义的函数,除0,等一些编译语法错误. 异常:是因为业务逻辑和流程,不符合预期情况,比如验证请求参数,不通过就用 ...