Egg: 关于路由的问题

Created on 26 Nov 2017  ·  5Comments  ·  Source: eggjs/egg

/camera/:id会匹配到/camera/count

Most helpful comment

如果你只想 id 是 Number,你需要改成正则。

'/camera/:id' => /^\/camera\/(\d{1,1000})\/?$/

All 5 comments

这是正常行为。自己调整路由注册顺序。可以再看看 koa-router 文档。

/camera/:id 会匹配到 /camera/count,不是很正常么?

如果你只想 id 是 Number,你需要改成正则。

'/camera/:id' => /^\/camera\/(\d{1,1000})\/?$/

100 就好了吧,1000 位的 ID。。。

@atian25 举例而已。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

popomore picture popomore  ·  70Comments

fengmk2 picture fengmk2  ·  44Comments

shaoshuai0102 picture shaoshuai0102  ·  52Comments

andylei18 picture andylei18  ·  35Comments

XadillaX picture XadillaX  ·  44Comments