参数接收

param参数 => /:  => 接收参数:this.$route.params.id

query参数  => ?  => 接收参数:this.$route.query.id

还有一种 meta值

路由复用

场景:当从Product/1  跳转到  Product/2 时,原来的组件实例被复用,两个路由渲染的是用一个组件,这时组件的生命周期钩子不会被二次加载;

export default {

created() {

获取参数

}

}

这里的获取参数将不会改变,相对路由参数做出变化:

export default {

watch: {

'$router' (to ,from) {

//对路由变化做出响应

}

}

}

传递参数 

由于query与params传参机制不一样,造成的差异,如果要隐藏参数用params,如果强制刷新不被清除用query

通过$router中name配置:
this.$router.push({
name: 'ProductList',
query:{
CategoryID: CategoryID
}
})
路由器配置name
问号?
this.$router.push({
path: `/ProductList?CategoryID=${id}`
})
this.$router.push({
  path: `/ProductList`,
  query: {
    CategoryID: CategoryID
  }
}) <router-link v-for="item in CategoryList" v-if="item.Level === 1" :key="item.id" :to="`/ProductList?CategoryID=${item.id}`">
通过路由器配置:
export default new Router({
routes: [
{
path: '/Product/:id',
name: 'Product',
component: Product
}
]
})
1)
<router-link :to="`/Product/${item.ID}`" v-for="item in ProductList">{{ item.ProductName }}</router-link>
<router-link :to="`{name:'Product',params:${item.ID}}`" v-for="item in ProductList">{{ item.ProductName }}</router-link>
2)
this.$router.push({
 path: `/ProductList/${CategoryID}`
})

最新文章

  1. 在一定[min,max]区间,生成n个不重复的随机数的封装函数
  2. .net 网络编程
  3. Codeforces Round #267 (Div. 2) C. George and Job DP
  4. empty与isset的一点使用体会
  5. springmvc简述
  6. 检测zookeeper和kafka是否正常
  7. 504 Gateway Time-out 和 502 Bad Gateway相关处理
  8. rancher 笔记 之 rancher应用中心
  9. 洛谷 P1093 奖学金
  10. CodeForces 631B Print Check
  11. R+大地图时代︱ leaflet/leafletCN 动态、交互式绘制地图(遍地代码图)
  12. 小白用阿里云搭载wordpress个人博客
  13. pytorch加载预训练模型参数的方式
  14. CMake在Visual Studio下保持目录结构
  15. amipy exampes
  16. C# ashx接收ContentType=&quot;text/xml&quot;类型值
  17. 算法笔记--java的BigInteger类及BigDecimal类
  18. [日常工作] SQLSERVER 数据库出问题..搜索到的有用的网页信息
  19. BaiduMap 鼠标绘制矩形选框四个顶角坐标的获取
  20. python 控制台输出带颜色的文字的方法

热门文章

  1. react项目开发环境搭建
  2. rtsp学习参考资料1
  3. BOF和EOF的详细解释 ADO的三个核心对象
  4. Win32汇编之其他指令
  5. SQL SERVER中Datetime时间的范围与.net的DateTime对象的区别
  6. C#异步编程学习笔记之-async和await(续)
  7. O048、掌握 cinder-scheduler 调度逻辑
  8. O033、Terminate Instance 操作详解
  9. 记录FTPClient超时处理的相关问题(转)
  10. OSCP-Kioptrix2014-1 环境搭建