router-link的使用方法
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="" name="Keywords">
<meta content="" name="description"/>
<title></title>
<link rel="icon" href="">
<style>
.router-link-active{
color: #ee2ad6;
}
</style>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> </head>
<body>
<div id="app">
<!-- router-link 标签上的tag 是修改展示的标签元素的 不写的话默认 a标签
active-class 是控制当前选中状态的类名的额,后边跟的值就是选中状态下的类名
不写这个属性,默认选中的类名就是 router-link-active
exact-active-class 精确(会把传的一些参数认成不同路径)匹配 路由
不写这个属性,默认选中的类名就是 router-link-exact-active
-->
<!-- <router-link to="/home" tag="button" active-class="current">首页</router-link>
<router-link to="/list" tag="button" exact-active-class="exactClass">列表页</router-link>-->
<!--query 这个单词是vue-router 规定的;
后边跟的是个对象,router会把对象中的每一项拼接到路由后边-->
<router-link :to="{path:'/home',query:{name:12,age:13}}">首页</router-link>
<!--params 这个单词也是vue-router规定的,它是对象中的参数当做路拼到之前的路径上
这个地方不能再用path跳转 必须用name跳转-->
<router-link :to="{name:'q',params:{name:12}}"> 列表页</router-link>
<router-view></router-view>
</div> </body>
</html>
<script src="node/node_modules/vue/dist/vue.js"></script>
<script src="node/node_modules/vue-router/dist/vue-router.js"></script>
<script> let home = {
template:"<h2>首页</h2>",
mounted(){
console.log(this.$route.query); //通过$route 可以获取路径上的参数
console.log(this);
}
};
let list = {
template:"<h2>列表页</h2>",
mounted(){
console.log(this.$route.params);
console.log(this);
}
}; const routes=[
{
path:'/home',
component:home
},
{
path:'/list/:name', //若想要路径传参,则需要在路径参数对应的位置写成:变量的形式
//这个变量会对应上 在行内设置的params对象中的属性名对应的属性值
name:'q', //若想用路径传参,则必须用name去指定跳转路径
component:list
}
];
const router=new VueRouter({
routes,
// mode:'history'
linkActiveClass:'current2' , //这个是给全局的选中状态下的 router-link修改类名
linkExactActiveClass:'activeClass'
});
let vm = new Vue({
el: '#app', data: {},
router,
created(){ },
directives: {},
methods: {},
computed: {},
watch: {},
filters: {}
})
</script>
router-link的使用方法的更多相关文章
- navigate是Router类的一个方法,主要用来跳转路由。
navigate是Router类的一个方法,主要用来跳转路由. 1 2 3 4 5 6 7 8 9 interface NavigationExtras { relativeTo : Activat ...
- [Redux] Navigating with React Router <Link>
We will learn how to change the address bar using a component from React Router. In Root.js: We need ...
- Vue router link
html: <router-link to="test">Go to Foo</router-link> <router-link to=" ...
- [React] React Router: Router, Route, and Link
In this lesson we'll take our first look at the most common components available to us in react-rout ...
- angular2 学习笔记 ( Router 路由 )
参考 : https://angular.cn/docs/ts/latest/guide/router.html#!#can-activate-guard https://angular.cn/doc ...
- React Router教程
React Router教程 React项目的可用的路由库是React-Router,当然这也是官方支持的.它也分为: react-router 核心组件 react-router-dom 应用于浏览 ...
- React Router 用法
React Router 用法 一.DEMO import React from "react"; import { HashRouter as Router, Route, Li ...
- React Router学习
React Router教程 本教程引用马伦老师的的教程 React项目的可用的路由库是React-Router,当然这也是官方支持的.它也分为: react-router 核心组件 react-ro ...
- react-router5.x 的配置及其页面跳转方法和js跳转方法
https://blog.csdn.net/sinat_37255207/article/details/90745207 上次用react-router 的时候 还是3.x 很久不用 已经到rea ...
- vue router应用及总结
编写一个小的demo,对router基础的应用学习和理解. 效果图示: 说明: 点击About在右边显示相关信息. 说明: 点击Home,在下边显示相关信息,且Home下有两个路由链接,分别对应各自的 ...
随机推荐
- word2vec中的数学原理(转)
- 使用Asp.net Identity 创建用户 、登录代码
1.Identity 1中的注册.登录.注销代码 vs 2013中自带的注册用户代码: 1.首先创建一个ApplicationUser 初始化用户名. 2.使用UserManager创建一个用户,用使 ...
- 51nod 1120 机器人走方格 V3 【卡特兰数+卢卡斯定理+组合数】
-我并不知道为什么事卡特兰数,反正用dp打的表就是卡特兰数,因为是两个三角所以再乘个2 卡特兰数使用\( h(n)=\frac{C_{2n}^{n}}{n+1} \)因为范围比较大所以组合数部分用卢卡 ...
- ionic2 angular2 模板指令补充
向div中插入带有html标签的数据 [innerHTML]="item.content" 字符串截取指令 {{item.de ...
- 题解报告:hdu1995汉诺塔V(递推dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1995 Problem Description 用1,2,...,n表示n个盘子,称为1号盘,2号盘,. ...
- 题解报告:hdu 1098 Ignatius's puzzle
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1098 题目中文是这样的: 伊格内修斯在数学上很差,他遇到了一个难题,所以他别无选择,只能上诉埃迪. 这 ...
- 解题报告:hdu 1073 Online Judge
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1073 Problem Description Ignatius is building an Onli ...
- WebSphere中数据源连接池太小导致的连接超时错误记录
WebSphere中数据源连接池太小导致的连接超时错误记录. 应用连接超时错误信息: [// ::: CST] webapp E com.ibm.ws.webcontainer.webapp.WebA ...
- IOS应用开发版本控制工具之Versions使用,iosversions
Versions版本控制工具破解版(Versions.zip)下载请见本博文附件.下载后在MAC安装完以后,图标是莲花状.见下图: 双击运行如下图: 点击Repository,连接SVN服务器R ...
- chromedriver与chrome版本对应
今天把手头有的一些关于selenium测试的资源整理了一下,分享出来. 1. 所有版本chrome下载 是不是很难找到老版本的chrome?博主收集了几个下载chrome老版本的网站,其中哪个下载的是 ...