vue-router
来源:互联网 发布:淘宝商品上架时间查询 编辑:程序博客网 时间:2024/05/22 17:00
前端路由优势:单页面应用中,无需多次请求服务器资源
使用vue-cli 构建的项目中,在src -> main.js 中配置路由
import "VueRouter" from "vue-router"引用vue-router 模块
Vue.use(VueRouter)注册使用vue-router
let router = new VueRouter({ mode:"history", routes:[ { path:'/', redirect:'/xxx' }, { path:'/foo', component:Foo }, { path:'/bar', name:bar, component:Bar } ]})
创建一个router实例,ps:使用组件前先要import引入
new Vue({ el:"myApp", router})
在vue实例中使用
router-link : 路径跳转 router-view:渲染组件
动态路由参数:路由映射中path 可以携带参数,vue实例会暴露$route属性让组件访问关于路由的一些属性,this.$route.params、this.$route.query、this.$route.path
编程式导航:router.push(path)、router.replace(path)
阅读全文
0 0
- vue-router
- vue-router
- vue-router
- vue-router
- Vue router
- vue-router
- vue-router
- vue-router
- vue-router
- vue-router
- vue-router
- vue-router
- vue-router
- vue-router
- vue-router
- vue-router
- vue-router
- vue 路由vue-router
- 迷宫问题
- 关于http请求报500错误问题
- Nginx隐藏index.php和Pathinfo模式配置例子
- iOS编程学习十六
- Unity3d 技巧(9) 游戏上线必备 适配Steam 安装包需要用到的资料
- vue-router
- 4412驱动实验之03 Menuconfig_Kconfig
- sort和qsort
- Elasticsearch批量导入本地Json文件Java实现
- 【Quartz】Quartz存储与持久化-基于quartz.properties的配置
- POJ 2112 Optimal Milking (二分+最大流/多重匹配) && POJ 2391 Ombrophobic Bovines( 二分+拆点+最大流)
- 55. Jump Game
- Minigame Learning for Day 2
- Java中的static关键字解析