是否有任何直接的方法来获取 URL 路径段而不需要任何附加数据(url 参数、css '#' 等)
例如:
完整网址:
http://example.com/panel/list
/panel/list
http://example.com/panel/list?user=joe
/panel/list
http://example.com/panel/list#header
/panel/list
以及不属于我的 URL 路径段的任何其他数据组合
对于不带任何参数的完整网址,您可以使用
req.protocol + '://' + req.get('host') + req.baseUrl + req.path;
在前端你可以使用window.location.pathname。