1

我正在尝试将routerjs用作独立库,但无法弄清楚如何实现文档中所述的处理程序查找,并且找不到任何示例。

到目前为止我得到了什么:

var router = new Router['default']()

router.map(function(match) {
  match('/').to('index')
  match('/chat').to('chat')
})

我已经尝试在这样的路由中使用回调,但是无论我使用什么 url,都会调用每个回调,所以我不确定如何使用它:

router.map(function(match) {
  match('/').to('index', function() {
    console.log('always called')
  })
  match('/chat').to('chat', function() {
      console.log('always called as well')
  })
})

有人成功使用过吗?

4

0 回答 0