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 ...
随机推荐
- Linux-开机启动程序
尝试一下几种方法: 1.修改 /etc/rc.local文件. 在exit0 前添加启动命令 2.在/home/pi/.config/autostart/ 下添加.desktop 在.config ...
- Powershell-常用脚本
function Test-Port { Param([string]$ComputerName,$port = 5985,$timeout = 1000) try { $tcpclient = Ne ...
- CEIWEI CommMonitor 串口监控精灵v11.0 串口过滤 串口监控
CEIWEI CommMonitor 串行端口监控精灵是用于 RS232 / RS422 / RS485 端口监控的专业 强大的系统实用程序软件.CEIWEI CommMonitor 监控显示, ...
- Anaconda基础使用
Windows下Anaconda操作:在Anaconda Prompt下执行 1. Anaconda 更新 conda update conda conda update anaconda conda ...
- Nginx服务rewrite模块功能说明 网站自动跳转功能
实现域名地址信息跳转,用于做伪静态地址 www.impkk.com/oldboy?edu.html 动态地址 www.impkk.com/oldboy-edu.html 伪静态地址 rewrite ^ ...
- JAVA HASH学习
就HASH的目的来说,是为了解决内容摘要与快速索引的问题:而其算法也比较多样. JDK实现中,对String类的hashcode()进行了重载: public int hashCode() { int ...
- C++11新特性之operator "" xxx(const char *, size_t n)
从C++11开始,我们可以使用以下形式通过常量字符串构造自定义类型, 比如: class Person { public: Person(const std::string& name): _ ...
- 题解 [51nod1225]余数之和
题解 [51nod1225]余数之和 题面 解析 首先可以发现,\(a\)%\(b\)\(=a-b*\lfloor a/b \rfloor\). 而对于一段连续的\(b\)来说\(\lfloor a/ ...
- 第五章 CSS美化网页元素
一.span标签:能让某几个文字或者某个词语凸显出来 <p> 今天是11月份的<span>第一天</span>,地铁卡不打折了 </p> 二.字体风格 ...
- ElementUI 之 Message,自动弹出,信息不显示问题
Vue.use() 这种写法可能会页面刷新时自动弹出 message,可将下图红框里换成 Vue.component(Message)