web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

vue3如何利用vue-router设置路由

390 ℃
     

vue3开发中如何利用vue-router设置路由,下面web建站小编给大家简单介绍一下!

1、安装vue-router

npm install vue-router@4.0.0-beta.13

2、设置路由文件

import { createRouter, createWebHashHistory } from "vue-router"
 
const routes = [
  {
    path: '/',
    component: () => import('@/index')       
  },
  {
    path: '/list',
    name: "list",
    component: () => import('@/pages/list')   
  },
  {
    path: '/about',
    name: "about",
    component: () => import('@/pages/about')   
  },
]
export const router = createRouter({
  history: createWebHashHistory(),
  routes: routes
})
 
export default router

Vue定义一个路由需要几步?

标签: vue-router路由, vue3设置路由

上面是“vue3如何利用vue-router设置路由”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_4761.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > vuejs
本文共计443个字,预计阅读时长3分钟
生活小工具,收录了80多款小工具
上一篇: 推荐一款免费开源的屏幕录制软件——OBS Studio
下一篇: 推荐一个高质量的图片素材网站——Unsplash
x 打工人ai神器