二级路由

#live demo #source code

二级路由需要用到 next() 方法传递下去,以及 res.subRoute() 生成二级页面渲染的节点

import SMERouter from 'sme-router'

const router = new SMERouter('router-view')

router.route('/main', (req, res, next) => {
  next(`
    <h2>Main title</h2>
    ${res.subRoute()}
  `)
})

router.route('/main/:content', (req, res, next) => {
  res.render(
    `Iam nested content`
  )
})

router.go('/main/sample')
上次更新: 2018-8-10 01:49:32