vite-plugin-vue-router
TypeScript icon, indicating that this package has built-in type declarations

1.0.18 • Public • Published

vite-plugin-vue-router

vite-plugin-vue-router is File system base vue-router plugin for Vite

Quick start

  1. install
yarn add vite-plugin-vue-router -D
  1. Use it in your project

Use it in vite.config.js

import configRouterPlugin from 'vite-plugin-vue-router';

export default defineConfig({
  plugins: [
    configRouterPlugin(),
  ],
});
  1. Introduce the required packages in main.js
import { createApp } from 'vue';
import App from '. /src/App.vue';
import router from '@pages-generated';
createApp(App).use(router).mount('#app');

4,middleware

//type1 test.js
//this type will be used as router.beforeEach
export default ({to,from,next}) => {}


//type2 test2.js
//this type will be used as router.beforeEach and router.afterEach
const beforeEach = ({to,from,next}) => {};
const afterEach = ({to,from}) => {};
export default {beforeEach,afterEach};

Project directory

vite-plugin-vue-router uses an agreed-upon directory format, so we need to follow this development style. It is often an effective measure to achieve uniformity and efficiency in a project.

├── public
├── src
    ├── layout
        ├─ Index.vue
    ├─ middleware
    ├── views
        └── Index.vue
    └── App.vue
├── index.html
├─ package.json
├─ vite.config.ts

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.18
    19
    • latest

Version History

Package Sidebar

Install

npm i vite-plugin-vue-router

Weekly Downloads

27

Version

1.0.18

License

MIT

Unpacked Size

37.6 kB

Total Files

7

Last publish

Collaborators

  • janzho