index.js
import VueRouter from 'vue-router'
//引入组件
import About from '../components/117/About.vue'
import Home from '../components/117/Home.vue'
import News from '../components/117/News.vue'
import Message from '../components/117/Message.vue'
import Detail from '../components/117/Detail.vue'
//创建路由器
export default new VueRouter({
/*
注意这里是routes不是routers不要写错了,
否则router-view会失效,且控制台会报No routes found in router
*/
routes:[
{
path:'/about',//路由
component:About,//组件名
},
{
path:'/home',//路由
component:Home,//组件名
children:[
{
path:'news',//对应home/news
component:News,
},
{
path:'message',
component:Message,
children:[
//query传参方式:?id=xx&title=yyy
// {
// name:'xiangqing',//路由命名
// path:'detail',
// component:Detail
// }
//params传参方式:id/xx/title/yyy
{
name:'xiangqing',//路由命名,params方式必须用name方式
path:'detail/:id/:title',
component:Detail
}
]
}
]
},
]
})
传参:
<router-link :to="{
name:'xiangqing',//注意这里是name不是path
params:{//这里是params不是query
id:m.id,
title:m.title
}
}">
{{ m.title }}
</router-link>
接收参数:<!--query传参时:$route.query.title,params传参时:$route.params.title-->
<li>消息标题:{{$route.params.title}}</li>
- 相关文章
- 初识vue
- 数据绑定:第一个vue例子
- vue模板语法
- vue数据绑定
- el与data的两种写法/延迟挂载
- vue数据代理-Object.definePropert
- vue事件及事件修饰符prevent/stop/
- vue计算属性computed
- vue(深度)监视属性watch
- vue绑定样式:class,:style
- 热门文章
- win7中将文件拷贝到虚拟机linux下
- phpexcel设置行高及列宽,背景颜色,
- rabbitmq无法启动
- intellij idea不显示git push按钮
- php7中使用mongodb的aggregate进行
- centos7.4 64位下swoole安装及配置
- laravel页面静态化的方法
- navicate连接mycat报1184错误
- 单点登录sso原理及php实现方式及de
- devops-jenkins容器为pending状态
- 好评文章
- phpexcel设置行高及列宽,背景颜色,
- php7中使用mongodb的aggregate进行
- intellij idea打开文件所在文件夹
- windows下使用MongoDB Compass Com
- win7中将文件拷贝到虚拟机linux下
- laravel 中悲观锁 & 乐观锁的使用
- 单点登录sso原理及php实现方式及de
- navicate连接mycat报1184错误
- rabbitmq无法启动
- laravel整合dingo/api方法步骤:jwt
- 我的项目
- 【github】www.github.com/hurong241
- 【码云】gitee.com/hu_rong/projects
- 【docker hub】hub.docker.com/repositories/hurong241
- 【packagist】packagist.org/users/hurong241/packages
- 站点信息
- 建站时间:2011年
- 文章数:607篇
- 浏览数:944440