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

/ 56,229评论 / 695016阅读 / 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. WilliamRen说道:

    https://cytotec.club/# buy cytotec in usa

  2. Davidfrify说道:

    cost of cheap propecia without insurance buy propecia without a prescription propecia generic

  3. RonaldSwobe说道:

    https://cytotec.club/# buy cytotec over the counter

  4. Jamesbub说道:

    На сайте коллегии юристов http://zpp-1.ru/ вы найдете контакты и сможете связаться с адвокатами. Юрист расскажет о том, как нужно правильно поступить, поможет собрать необходимые документы и будет защищать ваши права в суде. Квалифицированная юридическая и медицинская поддержка призывникам с гарантией!

  5. RandallGuesE说道:

    get cheap propecia tablets: get generic propecia tablets – buy cheap propecia for sale

  6. Davidfrify说道:

    nolvadex d nolvadex vs clomid tamoxifen warning

  7. WilliamRen说道:

    http://lisinopril.network/# buy lisinopril online usa

  8. RonaldSwobe说道:

    https://ciprofloxacin.tech/# buy ciprofloxacin

  9. WilliamRen说道:

    http://ciprofloxacin.tech/# buy cipro online

  10. WilliamRen说道:

    https://cytotec.club/# buy cytotec over the counter

  11. RandallGuesE说道:

    zestril 40 mg: lisinopril 5 mg india price – can you buy lisinopril over the counter

  12. Davidfrify说道:

    cytotec buy online usa purchase cytotec Cytotec 200mcg price

  13. RandallGuesE说道:

    tamoxifen skin changes: tamoxifen hormone therapy – where can i buy nolvadex

  14. RonaldSwobe说道:

    http://cytotec.club/# buy cytotec pills

  15. WilliamRen说道:

    http://cytotec.club/# buy cytotec online fast delivery

  16. Davidfrify说道:

    cost of propecia price get propecia pills propecia generics

  17. Davidfrify说道:

    order cheap propecia without prescription buying generic propecia buy propecia without prescription

  18. RandallGuesE说道:

    lexapro and tamoxifen: tamoxifen vs raloxifene – tamoxifen bone density

  19. Davidfrify说道:

    tamoxifen menopause tamoxifen tamoxifen hair loss

  20. WilliamRen说道:

    http://nolvadex.life/# tamoxifen brand name

  21. Davidfrify说道:

    lisinopril 10 mg daily buy zestril online lisinopril 10

  22. WilliamRen说道:

    https://lisinopril.network/# zestril medication

  23. RandallGuesE说道:

    Abortion pills online: cytotec pills online – buy cytotec

  24. RandallGuesE说道:

    cost of generic lisinopril: price of zestril – buy 20mg lisinopril

  25. RonaldSwobe说道:

    https://finasteride.store/# buy generic propecia without insurance

  26. WilliamRen说道:

    https://lisinopril.network/# lisinopril 20 mg coupon

回复 metformin 1000 mg price india 取消回复

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