vant4 van-tabbar组件使用

html 复制代码
<van-tabbar v-model="active" @change="onChange">
      <van-tabbar-item icon="home-o">1</van-tabbar-item>
      <van-tabbar-item icon="column">2</van-tabbar-item>
      <van-tabbar-item icon="chat">3</van-tabbar-item>
      <van-tabbar-item icon="manager">4</van-tabbar-item>
    </van-tabbar>
js 复制代码
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";

const router = useRouter();

let active = ref(0);
//获取当前路由使得刷新页面后,导航位置不变
onMounted(() => {
console.log("router.currentRoute",router.currentRoute);

  active.value =
    router.currentRoute.value.path == "/userRecruit"
      ? 0
      : router.currentRoute.value.path == "/jobFair"
      ? 1
      : router.currentRoute.value.path == "/messageview"
      ? 2
      : 3;
});

function onChange(index) {
  if (index == 0) {
    router.replace("/");
  } else if (index == 1) {
    router.replace("/");
  } else if (index == 2) {
    router.replace("/");
  } else if (index == 3) {
    router.replace("/");
  }
}
相关推荐
Highcharts.js1 分钟前
Highcharts React v4 迁移指南(上):核心变更解析与升级收益
前端·javascript·react.js·react·数据可视化·highcharts·v4迁移
SuniaWang6 分钟前
《Spring AI + 大模型全栈实战》学习手册系列 · 专题八:《RAG 系统安全与权限管理:企业级数据保护方案》
java·前端·人工智能·spring boot·后端·spring·架构
菌菌的快乐生活14 分钟前
在 WPS 中设置 “第一章”“第二章” 这类一级编号标题自动跳转至新页面
前端·javascript·wps
hh随便起个名40 分钟前
useRef和useState对比
前端·javascript·react
Hello_Embed1 小时前
LVGL 入门(十五):接口优化
前端·笔记·stm32·单片机·嵌入式
huabiangaozhi1 小时前
spring-boot-starter和spring-boot-starter-web的关联
前端
umeelove351 小时前
Spring boot整合quartz方法
java·前端·spring boot
吴声子夜歌1 小时前
JavaScript——对象
开发语言·javascript·ecmascript
小码哥_常1 小时前
Android 开发探秘:View.post()为何能获取View宽高
前端
爱学习的程序媛1 小时前
【Web前端】WebAssembly详解
前端·web·wasm