主干路由(spine js mvc)如何工作?
我已经尝试了 Spinejs 库几天,我在 Spinejs.com 上有文档,但直到现在,我仍然不知道 Spine 路由到底是如何工作的。从文档中,我知道如何创建新路由并将其添加到 Spine 路由中。但它是如何运作的呢? 我尝试创建一个带有 2 个控制器任务和 TaskList 的示例,这些控制器从 Spine.Controller 扩展,我还添加了 2 个路由控制器:“#/task”和“#/tasklist”:
Spine.route.add("#/task");
Spine.route.add("#/tasklist");
Spine.route.setup();
在任务和 TaskList 控制器中,我只是在他们的构造函数。
但是当我浏览:“http://hellospine.html/#task”->什么也没发生 然后“http://hellospine.html/#tasklist”->什么也没发生 我认为,url“#task”和“#tasklist”中的路由值让spine调用适当控制器的构造函数,但它不起作用。
你有什么想法吗?我应该再配置以使其运行适当的控制器吗?我也想知道spine路由的工作流程,请帮助我,非常感谢!
I have tried Spinejs library for a few days, I have the document on Spinejs.com but till now, I still don't know how exactly Spine routing work. From the document, I know how to create a new route and add them to Spine routing. But how it work?
I tried to create an example with 2 controller Task and TaskList extends from Spine.Controller, I also did add 2 routing controllers: "#/task" and "#/tasklist":
Spine.route.add("#/task");
Spine.route.add("#/tasklist");
Spine.route.setup();
in Task and TaskList controller, I simply alert an message in their constructor.
But when I browse: "http://hellospine.html/#task" -> nothing happen
then "http://hellospine.html/#tasklist" -> nothing happen
I thought that, the route values in url "#task" and "#tasklist" let spine call constructor of appropriate controller, but it's not working.
Do you have any idea ? Should I config anymore to make it run appropriate controller ? I also wanna know work flow of spine routing, please help me, thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
3 件事:
Spine.Route.add
应该在控制器之外使用。#
。,如下所示:
demo 此处
但请参阅http://spinejs.com/docs/routing
干杯。
3 things:
Spine.Route.add
is meant to be used out of controllers.#
.so:
demo here
But please refer to http://spinejs.com/docs/routing
Cheers.