Vue学习手记03-路由跳转与路由嵌套
1.路由跳转
- 添加一个LearnVue.vue文件,
- 在router->index.js中 引入import Learn from '@/components/LearnVue'
- 在touter中添加路由说明
export default new VR({
routes:[
{
path:"/hello",
name:"HelloWorld",
component:HelloWorld
},
{
path:"/learn",
name:"Learn",
component:Learn
}
]
})
4.在需要切换的地方使用标签router-link
<ul>
<router-link tag="li" to="hello"> hello</router-link>
<router-link to="learn"> learn</router-link>
</ul>
属性:
- to="hello"指定跳转的路由页面
- tag 可以用于指定router-link标签的渲染标签,tag="li"就是安装li的标签样式来渲染。
2.动态路由(参数传递)
/:id 多个参数就 /:id/:name
3.路由嵌套
01.引入子路由后
02.在创建路由时,添加一个children ,多级嵌套就添加多个children
export default new VR({
routes:[
{
path:"/hello",
name:"HelloWorld",
component:HelloWorld
},
{
path:"/learn",
name:"Learn",
component:Learn,
children:[
{
path:"base",
component:Base
}
]
}
]
})
03跳转的地方:to="/Learn/Base"这个要写全,不能只写Base
<router-link tag="li" to="/Learn/Base"> Base </router-link>
Vue学习手记03-路由跳转与路由嵌套的更多相关文章
- vue常用操作及学习笔记(路由跳转及路由传参篇)
路由跳转 - 超链接方式跳转 html: <div id="app"> <h1>Hello App!</h1> <p> <!- ...
- Vue学习手记02 - 路由
1.项目 注意:项目在初始化的时候没有安装vue-router就需要进行安装 2.安装路由: 在项目中使用ctrl+`, 打开终端, 执行如下命令 npm i vue-router -S 或者 cn ...
- Vue框架(四)——路由跳转、路由传参、cookies、axios、跨域问题、element-ui模块
路由跳转 三种方式: $router.push / $router.go / router-link to this.$router.push('/course'); this.$router.pus ...
- 路由传值及获取参数,路由跳转,路由检测,this.$route.query和this.$route.params接收参数,HttpGet请求拼接url参数
配置动态路由参数id: routes: [ // 动态路径参数 以冒号开头 { path: '/user/:id', component: User } ] html路由跳转: <router- ...
- Vue学习手记01-安装和项目创建
1.安装Vue 注:node版本必须大于等于8.9 vue-cli3.x:npm install -g @vue/cli vue-cli2.x:npm install -g @vue/cli-i ...
- vue学习 ---- 使用vue-router 进行跳转
前提说明,在学习vue的时候,尽量的以官网的为主,而且框架本身与官方文档都是在不断迭代更新的. 在vue的框架中,目前都是使用vue-router 来进行页面跳转的,而不是<a>.先贴一个 ...
- Vue学习手记09-mock与axios拦截的使用
01.安装 安装mock npm install mockjs 安装axios npm install axios 02.新建一个config.js文件做axios拦截 import axios fr ...
- Vue学习手记08-vue-cli的启动过程
分两种情况---无路由和有路由 无路由 看到启动页面 在文件main.js( vue项目的入口文件)中 这里可以看到,生成了一个全局的vue实例,绑定在了#app上面,也就是在文件index.html ...
- Vue学习手记04-跨域问题
01-安装axios,指令(npm install --save axios)02-解决跨域问题 在config=>中创建一个新的文件proxyConfig.js module.exports ...
随机推荐
- UI5-技术篇-jQuery.ajax执行过程中Token验证及JSON格式传值问题
最近两天在测试OData服务类方法CREATE_DEEP_ENTITY及GET_EXPANDED_ENTITYSET,刚开始采用ODataModel方式调用没有任何问题,但是ODataModel采用的 ...
- bootstrap tab选项卡
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 【JUC】2.synchronized
synchronized关键字的用法也不做太多笔记了,简单回顾一下: synchronized三种使用方式: 修饰实例方法: 线程获取的是当前调用此方法的对象的对象头:即:锁是当前对象: public ...
- layui列表表单
列表: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title ...
- Python中type()详解:动态创建类
众所周知: type()函数可以查看变量的类型: 先看一个简单的列子来看一下type查看变量类型 class Animal(): pass a=Animal() print(type(a)) prin ...
- Docker - Cheap sheet
** IMAGE ** $docker image Delete image : $docker image rm image_id make sure all containers be delet ...
- 25道Shell面试题
1. 用sed修改test.txt的23行test为tset: sed –i ‘23s/test/tset/g’ test.txt 2. 查看/web.log第25行第三列的内容. sed –n ‘2 ...
- centos 安装ELK
准备安装环境 由于本人的centos是通过虚拟机来进行安装的,为了本地电脑能够访问centos系统中的端口,则需要把防火墙进行关闭,通过以下方式进行关闭防火墙. # vi /etc/sysconfig ...
- 2019-ACM-ICPC-徐州站网络赛- I. query-二维偏序+树状数组
2019-ACM-ICPC-徐州站网络赛- I. query-二维偏序+树状数组 [Problem Description] 给你一个\([1,n]\)的排列,查询\([l,r]\)区间内有多少对 ...
- ES6 Class(类)的继承与常用方法
一.ES6 类的定义 ES5 构造函数的写法: function Point(x, y) { this.x = x; this.y = y; } ES6 引入了 Class(类),通过class关键字 ...