一。路由跳转

  在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. 使用docker-compose安装wordpress

    一.建立应用的目录 mkdir my_wordpress cd my_wordpress 二.创建 docker-compose.yml touch docker-compose.yml;vi doc ...

  2. vue模板语法上

    vue的插值案例 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...

  3. Invoke 与 BeginInvoke的区别

    引用文章路径:https://www.cnblogs.com/lsgsanxiao/p/5523282.html invoke和begininvoke 区别 一直对invoke和begininvoke ...

  4. 201871010107-公海瑜《面向对象程序设计(java)》第一周学习总结

    201871010107-公海瑜<面向对象程序设计(java)>第一周学习总结 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/   ...

  5. linux 安装程序的方式

    linux 安装程序的方式 通用二进制格式(绿色软件,打开即用) 软件包管理器(rpm) 软件包管理器的前端工具(yum) 源代码编译

  6. 《大数据技术应用与原理》第二版-第三章分布式文件系统HDFS

    3.1分布式文件 HDFS默认一个块的大小是64MB,与普通文件不同的是如果一个文件小于数据块的大小,它并不占用整个数据块的存储空间. 主节点又叫名称节点:另一个叫从节点又叫数据节点.名称节点负责文件 ...

  7. 游戏设计模式——Unity事件队列(纪念京阿尼事件)

    “对消息或事件的发送与受理进行时间上的解耦.” 在游戏开发过程中,经常会出现不同板块之间的信息交流,或是存在“当...,就...”的情况,事件队列编程模式可以有效解决消息传递中产生的脚本耦合问题,让同 ...

  8. hdu-6415 计数DP

    Nash Equilibrium is an important concept in game theory. Rikka and Yuta are playing a simple matrix ...

  9. go语言使用go-sciter创建桌面应用(八) 窗口显示时,自动加载后端数据。

    有些时候我们需要在窗口创建并显示时,加载一些后端的配置,这就需要用到view提供的几个事件. https://sciter.com/docs/content/sciter/View.htm state ...

  10. 死磕 java同步系列之CountDownLatch源码解析