day67_10_11
一。路由跳转
在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的更多相关文章
随机推荐
- elementui入门以及nodeJS环境搭建
1. ElementUI简介 我们学习VUE,知道它的核心思想式组件和数据驱动,但是每一个组件都需要自己编写模板,样式,添加事件,数据等是非常麻烦的, 所以饿了吗推出了基于VUE2.0的组件库,它的名 ...
- java8-08-创建stream流
为什么用stream 应用函数式编程 配合Lamdba表达式 更快操作集合类 数组 什么是 stream ...
- LG5337/BZOJ5508 「TJOI2019」甲苯先生的字符串 线性动态规划+矩阵加速
问题描述 LG5337 BZOJ5508 题解 设\(opt_{i,j}(i \in [1,n],j \in [1,26])\)代表区间\([1,i]\),结尾为\(j\)的写法. 设\(exist_ ...
- linux编程fcntl获取和设置文件锁
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types. ...
- CF 704 D. Captain America
CF 704 D. Captain America 题目链接 题目大意:给出\(n\)个点的坐标,你要将每个点染成红色或者蓝色.染一个红色要付出\(r\)的代价,染一个蓝色要付出\(b\)的代价.有\ ...
- IT兄弟连 HTML5教程 HTML5和HTML的关系
HTML5开发现在很火爆,是一门技术,更是一个概念.可以让我们的工作模式.交互模式以及对应用和游戏的体验有了翻天覆地的变化,很多人都知道HTML5这门技术,也常把HTML5读作H5(简称).其实一些外 ...
- 面试必问的Spring IOC详解
广义的 IOC IoC(Inversion of Control) 控制反转,即“不用打电话过来,我们会打给你”. 两种实现: 依赖查找(DL)和依赖注入(DI). IOC 和 DI .DL 的关系( ...
- 两种查看EFCore生成Sql语句的方法
一.利用反射生成查询语句 该方法转载自:https://jhrs.com/2019/28488.html (略有修改) using Microsoft.EntityFrameworkCore.Quer ...
- StreamWriter StreamReader
private void WriteLoginJsonData(object jsonData) { using (FileStream writerFileStream = new FileStre ...
- 数据库-表操作(CRUD)
1.数据增删改 2.单表查询 3.正则表达式 4.多表查询 笛卡尔积 内连接 外链接 子查询 一.数据的增删改 为什么不说查 因为查询语句 有很多细节 所以先从简单的说起 添加数据: ...