最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

關(guān)于vue-router路由的傳參方式params query

 更新時間:2023年10月08日 08:49:14   作者:Morning_xx  
這篇文章主要介紹了關(guān)于vue-router路由的傳參方式params query,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

vue-router路由的傳參方式params query

1.$router 和 $route的區(qū)別

  • $router : 路由操作對象、操作路由、包括路由的跳轉(zhuǎn)方法,鉤子函數(shù)等、只寫對象;
  • $route : 路由信息對象、獲取路由信息、包括path,params,hash,query,fullPath,matched,name等路由信息參數(shù)、只讀對象;
//操作 路由跳轉(zhuǎn)
this.$router.push({
    name:'hello',
    params:{
        name:'word',
        age:'11'
    }    
})
//讀取 路由參數(shù)接收
this.name = this.$route.params.name;
this.age = this.$route.param.age;

2.query傳參

  • path配合
  • 刷新頁面參數(shù)不丟失
//query傳參,使用path跳轉(zhuǎn)
this.$router.push({
    path:'second',
    query:{
        queryId:'20230129',
        queryName:'Emma'
}
)}
//query傳參接受
this.quertId = ths.$route.query.queryId
this.queryName = this.$route.query.queryName 

3.params傳參

  • 和name配合
  • 刷新頁面參數(shù)會丟失
//params傳參,使用name
this.$router.push({
    name:'second',
    params:{
        Id:'20230129',
        Name:'Emma'
}
)}
//query傳參接受
this.Id = ths.$route.params.Id
this.Name = this.$route.params.Name 
//路由
{
path:'/second/:id/:name',
name:'second',
component:() => import('@/view/second')
}

vue-router路由傳參,如果沒參數(shù)的話就跳轉(zhuǎn)回來

if (JSON.stringify(this.$route.params) == '{}') {
? ? this.$router.go(-1)
}

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

北辰区| 西充县| 三都| 安泽县| 略阳县| 河池市| 子洲县| 梁河县| 海林市| 衡南县| 宁远县| 勐海县| 巴彦县| 建德市| 龙海市| 湖北省| 安义县| 沂源县| 江陵县| 汉源县| 阳西县| 于都县| 农安县| 奉化市| 霍林郭勒市| 都安| 海原县| 隆回县| 新河县| 宁南县| 通州市| 鹿邑县| 漠河县| 邻水| 石屏县| 潢川县| 申扎县| 镇坪县| 盐城市| 焦作市| 济南市|