https://github.com/sgpinkus/my-vue-router
https://github.com/sgpinkus/my-vue-router
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sgpinkus/my-vue-router
- Owner: sgpinkus
- Created: 2024-09-09T23:29:01.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-11-05T23:02:38.000Z (7 months ago)
- Last Synced: 2025-02-28T13:45:50.787Z (3 months ago)
- Language: TypeScript
- Size: 181 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:HOME
CONTACT
...
// Programatic routing:
$router.dispatch({ name: 'contact' });
```