现在我试图路由到这样的一些可选路径。快速正则表达式路由可选路径
router.get('/foo/bar(.*)', function(req, res, next) {
console.log("baz");
});
为“栏”后接受任何条件,我已经写了这个代码,并对其进行测试,但这并没有工作。哪里不对?
现在我试图路由到这样的一些可选路径。快速正则表达式路由可选路径
router.get('/foo/bar(.*)', function(req, res, next) {
console.log("baz");
});
为“栏”后接受任何条件,我已经写了这个代码,并对其进行测试,但这并没有工作。哪里不对?
你必须尝试这个以下路径模式:
// will match paths starting with /foo/bar and after this any string
router.get('/foo/bar*', function(req, res, next) {
console.log("baz");
});
它为我工作。查看Express Doc
这非常适用!谢谢!! – yosh