A lightweight router lib that implement with express route style
npm i --save sme-router
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>SME Router</title>
</head>
<body>
<div id="app">
<div id="router-view"></div>
</div>
</body>
</html>
import SMERouter from 'sme-router'
const router = new SMERouter('router-view')
// route config
router.route('/index', (req, res, next) => {
res.render(
`hallo world`
)
})
router.route('*', (req, res, next) => {
res.redirect('/index')
})
Note: if your are not using webpack, your can simply import it to your html file
<script type="text/javascript" src="https://unpkg.com/sme-router"></script>
Please see the document for more details
1.clone the repo
npm i
npm run dev
2.Test
npm run test // or => karma start
3.lint
npm run lint
Thanks goes to these wonderful people (emoji key):
hwen 🤔 💻 🎨 📖 💡 |
---|
Copyright (c) 2017-present, hwen hwenleung@gmail.com