前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >vue路由跳转

vue路由跳转

作者头像
不爱吃糖的程序媛
发布2024-01-18 21:06:59
780
发布2024-01-18 21:06:59
举报
1.需求分析

点击A页面的一个卡片,跳转到B页面的对应的tabItem项的页面。 A页面:

在这里插入图片描述
在这里插入图片描述

B页面:

在这里插入图片描述
在这里插入图片描述
2.源代码

A.vue

代码语言:javascript
复制
//截取的是关键代码
//点击货架卡片的方法
 <div class="warehouse-card"
   @click.stop="enterIntoShelfManagement(item.houseName, item.houseSn)">
   <div class="img">
     <img
       src="../../../assets/imgs/goods.png"
       style="width: 60px;height: 60px;"
     />
   </div>
   <div class="title">{{ $t("lang.cargo") }}</div>
   <div class="subTitle">
     {{ item.goodsCount }}{{ $t("lang.type") }}
   </div>
 </div>

<script>
enterIntoShelfManagement(warehouseName, warehouseSn) {
      this.$router.push({
        path: "/warehouseList/manage",
        query: { warehouseName, warehouseSn,tabItem:'shielf'},
      });
    },
</script>

B.vue

代码语言:javascript
复制
<template>
  <div class="container">
    <div class="container-header">
      <span @click="goBack">{{ $t("lang.warehouse") }}</span>
      <Icon
        link="icon-icon_page_next"
        customStyle="width:14px;height:14px;color:#999;"
      ></Icon>
      <span @click="goBackStock">{{ warehouseName }}</span>
    </div>
    <div class="container-body">
      <div class="warehouse-tab-header">
        <div
          :class="tabItem == 'stock' ? 'isActived' : ''"
          @click="clickTab('stock')"
        >
          {{ $t("lang.stockManage") }}
        </div>
        <span></span>
        <div
          :class="tabItem == 'shielf' ? 'isActived' : ''"
          @click="clickTab('shielf')"
        >
          {{ $t("lang.shielfManage") }}
        </div>
        <span></span>
        <div
          :class="tabItem == 'device' ? 'isActived' : ''"
          @click="clickTab('device')"
        >
          {{ $t("lang.deviceManage") }}
        </div>
      </div>
      <div class="warehouse-tab-content">
        <StockManage
          v-if="tabItem == 'stock'"
          :warehouseSn="warehouseSn"
        ></StockManage>
        <ShelfManage
          v-if="tabItem == 'shielf'"
          :warehouseSn="warehouseSn"
        ></ShelfManage>
        <DeviceManage
          v-if="tabItem == 'device'"
          :warehouseSn="warehouseSn"
        ></DeviceManage>
      </div>
    </div>
  </div>
</template>

<script>
import StockManage from "./stockManage/stockManage.vue";
import ShelfManage from "./shelfManage/shelfManage.vue";
import DeviceManage from "./deviceManage/deviceManage.vue";
// import { threadId } from "worker_threads";

export default {
  components: {
    StockManage,
    ShelfManage,
    DeviceManage
  },
  data() {
    return {
      // tabItem: "stock",
      tabItem: "",
      warehouseSn: "",
      warehouseName: ""
    };
  },
  mounted(){
    console.log("tabItem",this.tabItem)
  },
  created() {
    if (this.$route.query.warehouseName) {
      this.warehouseName = this.$route.query.warehouseName;
    }
    if (this.$route.query.warehouseSn) {
      this.warehouseSn = this.$route.query.warehouseSn;
    }
      if (this.$route.query.tabItem) {
      this.tabItem = this.$route.query.tabItem;
    }

  },
  methods: {
    clickTab(param) {
      this.tabItem = param;
      //   Storage.sessionSet('tabItem', param)
    },
    goBack() {
      this.$router.push("/warehouseList");
    },
    goBackStock() {
      this.tabItem = "stock";
    }
  }
};
</script>
3.思路总结

其实点击不同卡片跳转到同一页面的不同tabItem项下面的页面,其实就是多带一个tabItem参数。 就是这么简单!

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2024-01-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.需求分析
  • 2.源代码
  • 3.思路总结
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档