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')
})
注意: 如果你的项目没有使用 webpack 等构建工具,你可以通过 html 引入
<script type="text/javascript" src="https://unpkg.com/sme-router"></script>
具体用法请见 文档
1.先clone仓库
npm i
npm run dev
打开 http://localhost:8080/ 即可看到 example
2.测试
npm run test // or => karma start
3.lint
npm run lint
Thanks goes to these wonderful people (emoji key):
hwen 🤔 💻 🎨 📖 💡 |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
Copyright (c) 2017-present, hwen [email protected]