1.2.2 • Published 8 months ago

@sgpinkus/my-vue-router v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

MY-VUE-ROUTER

Simple 250LOC single file alternative to vue-router, with many fewer features.

  • Simple flat routing table - no nested.
  • No entry guards, no async, no name views, no ...
  • Using path-to-regexp for param parsing.
  • Works transparently with #fragments.

USAGE

main.ts

import { createRouter } from './my-vue-router'
import HomePage from '@/pages/Home.vue';
import ContactPage from './pages/Contact.vue';
import NotFoundPage from './pages/NotFound.vue';
import App from './App.vue';

const app = createApp(App);

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomePage,
  },
  {
    path: '/contact',
    name: 'contact',
    component: ContactPage,
  },
  {
    path: '/*pathMatch',
    name: 'not-found',
    component: NotFoundPage,
    routeProp: true,
  },
];

app.use(createRouter(routes));

xxx.vue

...
// Template components:
<route-view></route-view>
<route-path :path='/home'>HOME</route-path>
<route-name :name='contact'>CONTACT</route-path>
...
// Programatic routing:
$router.dispatch({ name: 'contact' });
1.2.2

8 months ago

1.2.1

9 months ago

1.2.0

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago