1.2.2 • Published 1 year ago

@sgpinkus/my-vue-router v1.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago