在查看 emberjs 示例代码时,我遇到了这段代码
App.Router.map(function() {
"use strict";
this.route("channelr", {path: "/:url"});
this.route("postr", {path: "/:channel/:url"});
});
任何人都可以用示例解释一下这实际上意味着什么,尤其是 url
事情
最佳答案
配置对象path
值是路由器用来匹配模式的字符串。当名称以冒号 (:
) 开头时,它是变量的占位符。因此,如果用户访问“/123”,则将使用 ChannelrRoute
,并向 model
函数传递一个名为 url
属性的参数.
关于javascript - 解释 emberjs 代码中的 App.Router.map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21475601/