小工具知识网

当前位置: 首页 > 行业知识 > Vue3全家桶 - VueRouter - 【2】重定向路由

行业知识

Vue3全家桶 - VueRouter - 【2】重定向路由

2026-11-18 18:20:17 来源:互联网转载

重定向路由

  • 在路index.php/tags-41973.html" >���规则数组中,可采用 redirect 来重定向到另一个地址:
    • 通常是将 / 重定向到 某个页面;
    • 示例展示:
      • router/index.js:
        import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'// TODO 创建路由规则数组const routes = [  {    path: '/',    // 路由重定向    redirect: '/home'  },  {    path: '/home',    name: 'home',    component: () => import('@/views/HomeVue.vue')  },  {    path: '/blog',    name: 'blog',    component: () => import('@/views/BlogHomeVue.vue')  }]// TODO 创建路由const router = createRouter({  // TODO 规定路由模式  // history: createWebHashHistory(),  history: createWebHistory(),  routes})export default router
      • App.vue:
        import { ref, reactive, computed, onMounted } from 'vue'onMounted(() => {});  路由重定向 到 首页 |   首页 |   博客  
      • 运行效果展示:

上一篇:冰点下载器电脑版下载攻略,高速体验,一键轻松获取

下一篇:怎么爆破ftp服务器?