vue 路由跳轉傳遞參數使用query


vue路由跳轉傳遞參數:

1、使用params,但是這種方式在頁面刷新的時候會出現很多問題,需要在路由中配置

2、使用query頁面刷新不會存在問題也不需要在路由中配置

   {
      path:'/detail',
      component: detail,

   }

  使用方法:

  傳遞參數(JS中):  

    this.$router.push({
          path: '/detail', query:{shopid: item.id}

          });

  傳遞參數(頁面中):

    <router-link :to="{ path:'/detail', query: {shopid: item.id} }"><button>顯示<button></router-link>

    <router-link :to="`/detail?id=${item.id}`"><button>顯示</button></router-link>

  獲取參數:

    this.$route.query.shopid

  url的表現形式(url中帶有參數):

    http://localhost:8080/#/detail?shopid=1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM