Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Elixir 的 Phoenix Web 框架中,as: :pagesinget "/pages/:page", PageController, :show, as: :pages做了什么?其次,什么是as:宏?一张地图?
as: :pages
get "/pages/:page", PageController, :show, as: :pages
as:
该as:选项允许您自定义我们生成的命名路由器辅助函数以重新创建定义的路由。即来自文档:
命名的助手也可以使用该:as选项进行自定义。给定路线:
:as
get "/pages/:page", PageController, :show, as: :special_page
命名的助手将是:
MyApp.Router.Helpers.special_page_path(:show, "hello") "/pages/hello"
as:在这种情况下是路由器宏的一个选项,而不是宏本身。