[vue/vite/router]在vscode中给vite项目安装路由router/配置文件路由

/ 61,549评论 / 816257阅读 / 9点赞

安装router

import { createRouter, createWebHistory } from "vue-router"

const router = createRouter({
    routes: [],
    history: createWebHistory()
})

export default router

修改main.js

import { createApp } from 'vue'
import App from './App.vue'
import router from "./modules/router"

const app = createApp(App)

app.use(router)
app.mount('#app')

创建pages

<template>
    <router-view></router-view>
</template>

在router.js中配置页面

        {
            name:"主页",
            component: () => import('../pages/home.vue')
        },
        {
            name:"欢迎",
            path:"/hello",
            component: () => import('../pages/hello.vue')
        }
import { createRouter, createWebHistory } from "vue-router"

const router = createRouter({
    routes: [
        {
            name:"主页",
            component: () => import('../pages/home.vue')
        },
        {
            name:"欢迎",
            path:"/hello",
            component: () => import('../pages/hello.vue')
        }
    ],
    history: createWebHistory()
})

export default router

配置文件路由

当我们增加页面时,总要在router中配置一下,一旦页面多起来就很麻烦,所以可以安装文件路由,也就是以文件夹pages内的文件结构自动作为访问路径。

import Pages from "vite-plugin-pages"

export default defineConfig({
    plugins:[

        //...
        Pages(),
    ]
})
import { createRouter, createWebHistory } from "vue-router"
import routes from "~pages";

const router = createRouter({
    routes,
    history: createWebHistory()
})

export default router
  1. Arnoldscava说道:

    mexican pharmacy mexico drug stores pharmacies mexico pharmacies prescription drugs

  2. NelsonSaIlk说道:

    mexican pharmaceuticals online: buying prescription drugs in mexico online – mexican online pharmacies prescription drugs

  3. NelsonSaIlk说道:

    pharmacies in mexico that ship to usa: medicine in mexico pharmacies – п»їbest mexican online pharmacies

  4. RichardMonge说道:

    https://mexicandeliverypharma.online/# pharmacies in mexico that ship to usa

  5. RichardMonge说道:

    https://mexicandeliverypharma.online/# buying prescription drugs in mexico online

  6. Arnoldscava说道:

    mexico drug stores pharmacies mexican mail order pharmacies buying from online mexican pharmacy

  7. Waynetar说道:

    buying prescription drugs in mexico: mexican mail order pharmacies – mexico drug stores pharmacies

  8. Waynetar说道:

    best online pharmacies in mexico: mexican drugstore online – mexican pharmaceuticals online

  9. DominicHOr说道:

    п»їbest mexican online pharmacies: buying prescription drugs in mexico – buying prescription drugs in mexico

  10. DominicHOr说道:

    best online pharmacies in mexico: best online pharmacies in mexico – mexican pharmaceuticals online

  11. Uazrszy说道:

    Добрый день!
    Где приобрести диплом по нужной специальности?
    vlasti.biz/202112192678/bor-ba-s-korruptsciei/novosti/kupit-diplom-o-srednem-obrazovanii.html

  12. Waynetar说道:

    pharmacies in mexico that ship to usa: medicine in mexico pharmacies – mexico drug stores pharmacies

  13. DominicHOr说道:

    buying prescription drugs in mexico online: mexico drug stores pharmacies – mexican mail order pharmacies

  14. Waynetar说道:

    mexico pharmacies prescription drugs: mexican mail order pharmacies – п»їbest mexican online pharmacies

  15. DominicHOr说道:

    reputable mexican pharmacies online: mexico pharmacies prescription drugs – best online pharmacies in mexico

  16. Arnoldscava说道:

    mexican border pharmacies shipping to usa mexican online pharmacies prescription drugs medicine in mexico pharmacies

  17. Dnrtwwd说道:

    Привет!
    Заказать документ института можно в нашей компании в Москве.
    ast-diplomas.com/kupit-diplom-sankt-peterburg
    Удачи!

  18. RichardMonge说道:

    https://mexicandeliverypharma.com/# mexican online pharmacies prescription drugs

  19. Lazrrxh说道:

    Добрый день!
    Мы можем предложить дипломы любой профессии по приятным ценам.
    horn-fahrzeugaufbereitung.de/купить-дипломы-олимпиад

  20. RichardMonge说道:

    http://mexicandeliverypharma.com/# buying prescription drugs in mexico

  21. Diplomi_dyol说道:

    Привет, друзья!
    Заказать документ о получении высшего образования вы имеете возможность у нас.
    diplomasx.com/kupit-diplom-perm

  22. Arnoldscava说道:

    mexico drug stores pharmacies best online pharmacies in mexico mexican border pharmacies shipping to usa

  23. Mazrrcd说道:

    Здравствуйте!
    Всё, что нужно знать о покупке аттестата о среднем образовании без рисков
    mans-diploms.ru

  24. JamesLer说道:

    Discover Kyrie Irving’s https://mavericks-de-dallas.kyrie-irving-fr.com journey with the Dallas Mavericks, from his early days to forming a power duo with Luka Doncic and competing for a championship.

  25. Arnoldscava说道:

    mexican rx online mexico pharmacy medicine in mexico pharmacies

  26. Mary说道:

    Hey there! I realize this is kind of off-topic however I had
    to ask. Does building a well-established blog such as yours require a lot
    of work? I am brand new to writing a blog however
    I do write in my journal on a daily basis. I’d like to start a blog
    so I can share my experience and feelings online. Please let me know if you have any kind of ideas or tips for brand new aspiring blog owners.
    Thankyou!

  27. Waynetar说道:

    mexican rx online: buying prescription drugs in mexico online – mexican border pharmacies shipping to usa

  28. DominicHOr说道:

    medicine in mexico pharmacies: mexico drug stores pharmacies – mexican online pharmacies prescription drugs

  29. Waynetar说道:

    medication from mexico pharmacy: medication from mexico pharmacy – reputable mexican pharmacies online

  30. DominicHOr说道:

    reputable mexican pharmacies online: medicine in mexico pharmacies – buying from online mexican pharmacy

  31. RichardMonge说道:

    http://mexicandeliverypharma.com/# п»їbest mexican online pharmacies

  32. Arnoldscava说道:

    mexican pharmaceuticals online п»їbest mexican online pharmacies buying from online mexican pharmacy

  33. Treftii说道:

    Привет!
    Легальная покупка диплома о среднем образовании в Москве и регионах
    gaiassulin.com/диплом-о-среднем-образовании-как-и-где.html
    Всегда вам поможем!.

  34. Waynetar说道:

    buying prescription drugs in mexico online: buying prescription drugs in mexico online – buying prescription drugs in mexico

  35. DominicHOr说道:

    purple pharmacy mexico price list: mexico pharmacies prescription drugs – mexican mail order pharmacies

  36. Lazrizs说道:

    Здравствуйте!
    Мы изготавливаем дипломы любой профессии по доступным тарифам.
    ciscoworld.de/купить-диплом-о-высшем-образовании-че

  37. Waynetar说道:

    mexico pharmacies prescription drugs: mexico drug stores pharmacies – pharmacies in mexico that ship to usa

  38. DominicHOr说道:

    buying prescription drugs in mexico online: buying from online mexican pharmacy – mexican online pharmacies prescription drugs

  39. Arnoldscava说道:

    mexican pharmaceuticals online п»їbest mexican online pharmacies mexico drug stores pharmacies

  40. Nicole说道:

    Great delivery. Great arguments. Keep up the great work.

  41. Richardditly说道:

    Частная платная клиника https://mypsyhealth.ru психиатрии, психологии, психотерапии и наркологии анонимно в Москве.

  42. Arnoldscava说道:

    п»їbest mexican online pharmacies buying prescription drugs in mexico pharmacies in mexico that ship to usa

  43. RichardMonge说道:

    https://mexicandeliverypharma.com/# buying prescription drugs in mexico online

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注