Skip to content

Latest commit

 

History

History
118 lines (81 loc) · 2.89 KB

README.zh.md

File metadata and controls

118 lines (81 loc) · 2.89 KB

SME Router

A lightweight router lib that implement with express route style

Travis branch coverage download version license

语言

文档

Get Start

安装

npm i --save sme-router

·

用法

Edit sme-router example

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>

具体用法请见 文档

在线 Demo

点我看Demo

在本地跑

1.先clone仓库

npm i
npm run dev

打开 http://localhost:8080/ 即可看到 example

2.测试

npm run test // or => karma start

3.lint

npm run lint

Contributors

Thanks goes to these wonderful people (emoji key):


hwen

🤔 💻 🎨 📖 💡

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT License

Copyright (c) 2017-present, hwen [email protected]