Skip to content

sidmonta/simplebasicroute

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple basic route

A very basic route in typescript with dynamic import for SPA It's use the hash in URL for change the route

Usage

Import:

import { Route, Router } from './index'

Init route manager:

// Js/Ts

let routeManager = new Router([
  new Route('login', 'login.html', true, ['./login.js']),
  new Route('account', 'add-account.html'),
  new Route('calc', 'calc.html', false, ['./result.js']),
  new Route('result', 'result.html')
], '#container')
<!-- In html -->
...
<a href="#result" title="Example">Click</a>
...

Interface

  • The Router istance take an array of Route and the query for select the DOM element where change the content of the site.

  • The Route istance take:

    • name: name of route in URL
    • htmlName: The name of file with the view
    • [default] : if is the default view
    • [importFiles]: the list of javascript file to import when a page is loaded

About

A very basic route in typescript with dynamic import

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published