我正在检查 FW/1 的配置。我注意到有些路线以 a 开头,/
而另一些则不是。两者有什么区别吗?
variables.framework.routes = [
{ "chart/home" = "chart/home"},
...
{ "/location/home" = "location/home"},
我正在检查 FW/1 的配置。我注意到有些路线以 a 开头,/
而另一些则不是。两者有什么区别吗?
variables.framework.routes = [
{ "chart/home" = "chart/home"},
...
{ "/location/home" = "location/home"},
你注意到两者的行为有什么不同吗?我不认为有区别。从我可以找到的文档和示例中,它们都以/
. 我认为 FW/1 允许两者,但它们的工作方式相同。
这里的文档片段 - http://framework-one.github.io/documentation/developing-applications.html#url-routes:
URL 路由
除了 FW/1 支持的标准
/section/item
和/module:section/item
URL...
该页面下方的示例显示了以 a 开头的标准路线/
:
这是一个显示所有功能的示例:
variables.framework.routes = [ { "/product/:id" = "/product/view/id/:id", "/user/{id:[0-9]+}" = "/user/view/id/:id", hint = "Display a specific product or user" }, { "/products" = "/product/list", "/users" = "/user/list" }, { "/old/url" = "302:/new/url" }
];
这是处理您定义的路由的代码的链接 - https://github.com/framework-one/fw1/blob/develop/framework/one.cfc#L1954-L2047
为了测试这个理论,您可以尝试以下方法。
www.yourdomain.com/location/home
应该与您的示例中的第二条路线匹配。www.yourdomain.com/chart/home
应该匹配您示例中的第一条路线。www.yourdomain.com/sometextchart/home
与您的示例中的第一条路线匹配吗?www.yourdomain.com/somefolder/chart/home
与您的示例中的第一条路线匹配吗?www.yourdomain.com/somefolder/sometextchart/home
与您的示例中的第一条路线匹配吗?