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

/ 56,143评论 / 693009阅读 / 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. RandallGuesE说道:

    buy ciprofloxacin over the counter: purchase cipro – cipro generic

  2. WilliamRen说道:

    https://finasteride.store/# get cheap propecia no prescription

  3. RandallGuesE说道:

    tamoxifen breast cancer prevention: nolvadex steroids – where to get nolvadex

  4. WilliamRen说道:

    http://finasteride.store/# cost of propecia online

  5. WilliamRen说道:

    https://finasteride.store/# buying propecia without a prescription

  6. WilliamRen说道:

    https://ciprofloxacin.tech/# buy generic ciprofloxacin

  7. JamesKab说道:

    На этом сайте https://www.rabota-zarabotok.ru/ вы найдете полезную информацию, и отзывы о разных финансовых сайтах. Здесь очень много полезной информации, и разоблачение мошенников. А также узнайте где начать зарабатывать первые деньги в интернете.

  8. Davidfrify说道:

    ciprofloxacin mail online cipro where can i buy cipro online

  9. RandallGuesE说道:

    lisinopril 5 mg brand name: price for 5 mg lisinopril – zestril brand name

  10. Davidfrify说道:

    30mg lisinopril lisinopril 10 mg order online lisinopril 12.5 mg tablets

  11. RonaldSwobe说道:

    http://lisinopril.network/# lisinopril cost

  12. Davidfrify说道:

    buy generic ciprofloxacin ciprofloxacin 500mg buy online buy cipro online

  13. RandallGuesE说道:

    buy cipro online: buy cipro – buy generic ciprofloxacin

  14. WilliamRen说道:

    https://ciprofloxacin.tech/# buy generic ciprofloxacin

  15. RandallGuesE说道:

    order propecia without rx: generic propecia tablets – cost generic propecia without a prescription

  16. WilliamRen说道:

    http://nolvadex.life/# tamoxifen postmenopausal

  17. WilliamRen说道:

    http://nolvadex.life/# tamoxifen lawsuit

  18. RonaldSwobe说道:

    https://cytotec.club/# cytotec abortion pill

  19. Davidfrify说道:

    what is tamoxifen used for tamoxifen dosage clomid nolvadex

  20. Davidfrify说道:

    buy cytotec over the counter buy cytotec in usa Cytotec 200mcg price

  21. WilliamRen说道:

    https://lisinopril.network/# how to buy lisinopril online

  22. Dennisdrync说道:

    Компания КЗТО https://radiators-teplo.github.io/ известна производством высококачественных радиаторов, которые обеспечивают эффективное отопление и долговечность. Продукция КЗТО включает радиаторы различных модификаций, подходящие для любых помещений. Они изготавливаются из прочных материалов, что гарантирует устойчивость к коррозии и высокую теплоотдачу.

  23. Davidfrify说道:

    ciprofloxacin cipro buy generic ciprofloxacin

  24. RandallGuesE说道:

    clomid nolvadex: dcis tamoxifen – femara vs tamoxifen

发表回复

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