博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vue 路由(二级)配置及详细步骤
阅读量:6872 次
发布时间:2019-06-26

本文共 1012 字,大约阅读时间需要 3 分钟。

1、安装插件(可以选择在初始化项目的时候安装)

cnpm install vue-router --save-dev

2、将插件全局引入到项目中(main.js)

import VueRouter from 'vue-router'

3、将插件注入到vue中(main.js)

Vue.use(VueRouter) //全局使用该组件

4、创建组件(需要跳转的页面),举例如下:

5、配置路由(router.js),先引入组件,再写配置,最后导出(export...)

6、生成router实例(main.js)并传routes(路由)配置

  先将 router.js 引入进来 

import routers from './router/router'
const router = new VueRouter({  mode:'history', //模式  routes:routers  //routes是一组路由
})

7、生成 vue 实例 (main.js),并将路由注入到整个项目

new Vue({  el: '#app', //挂载根实例  router,//注入到根目录中  components: { App },  template: '
'})

 8、在项目主组件(APP.vue)中写路由跳转,例:

或者:

this.$router.push({    path: '/orderCommit',    query: {        date: this.dateValue    }})

二、二级路由

  1、在一级路由的基础上,路由配置中加上children

  2、在一级组件中加上显示

OK~

 

this.
$router.
push({
path:
'/orderCommit',
query: {
date:
this.
dateValue,
timeSlot:
this.
timeState,
timeSlotLast:
this.
timeSlotLast,
tableInfo:
myTableInfo,
tableId:
this.
tableIdStr,
isCourt:
this.
isCourt,
peopleNum:
peopleNum
}
})

转载于:https://www.cnblogs.com/candy-Yao/p/9378120.html

你可能感兴趣的文章
27、通过visual s'tudio 验证 SOCKET编程:搭建一个TCP服务器
查看>>
docker之Dockerfile实践
查看>>
JS堆栈与拷贝
查看>>
P3224 [HNOI2012]永无乡
查看>>
插件就是生产力——那些不能错过的XCode插件们
查看>>
Python打造一个在线G代码生成器
查看>>
ionic开发-怪癖001(http请求 android下无法正常运行)
查看>>
Java实现的基于socket的一次通信
查看>>
Form保存顺序
查看>>
[python]错误检测及异常处理try-except
查看>>
SharePoint 2010 "客户端不支持使用windows资源管理器打开此列表" 解决方法
查看>>
ZOJ-2913 Bus Pass---BFS进阶版
查看>>
合并排序(非哨兵方法)
查看>>
PHP 依赖管理神器 Composer 基本使用
查看>>
sass进阶篇
查看>>
为项目配置logback日志
查看>>
另外一种C#多选下拉框
查看>>
伸展树的学习(七):伸展树常用的操作合集
查看>>
在Windows Server 2008 R2上安装 PowerShell 5.0
查看>>
Hyper-V 2016 系列教程32 StartWind 虚拟NFS,iSCSI软件
查看>>