0

我正在检查 FW/1 的配置。我注意到有些路线以 a 开头,/而另一些则不是。两者有什么区别吗?

variables.framework.routes = [
   { "chart/home"                           = "chart/home"},
   ...
   { "/location/home"                       = "location/home"},
4

1 回答 1

3

你注意到两者的行为有什么不同吗?我不认为有区别。从我可以找到的文档和示例中,它们都以/. 我认为 FW/1 允许两者,但它们的工作方式相同。

这里的文档片段 - http://framework-one.github.io/documentation/developing-applications.html#url-routes

URL 路由

除了 FW/1 支持的标准/section/item/module:section/itemURL...

该页面下方的示例显示了以 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与您的示例中的第一条路线匹配吗?
于 2016-01-12T13:18:16.903 回答