如何创建动态URL与流星?

编程入门 行业动态 更新时间:2024-10-16 18:30:18
本文介绍了如何创建动态URL与流星?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我新的Web开发,并通过在流星的现场演示交口称赞,并想使用它。我只用谷歌应用程序引擎,到目前为止并在主类来处理动态URL我会写这样的事:

I'm new to web dev and was blown away by the demo on Meteor's site and would like to use it. I've only used Google App Engine so far and to handle a dynamic URL in the main class I would write something like this:

app = webapp2.WSGIApplication([('/[0-9]', HandlePost)], debug=True)

这将任何网址与数字0到9月末到处理程序类,会与使用模板引擎的网页,如把手适当的数据加载HTML页面映射。

This would map any URL's with the numbers 0 through 9 at the end to a handler class that would load an HTML page with the appropriate data for a page using a templating engine such as handlebars.

我该怎么做类似的东西在流星?

How do I do something similar in Meteor?

推荐答案

使用骨干路由器,请参阅: backbonejs/#Router-routes 结果对于像你的例子正则表达式看:blog.rjzaworski/2011/12/regex-routing-with-backbone-js/试用待办事项例子上的流星,请参阅客户端/ todo.js 文件:

Use backbone's router, see: backbonejs/#Router-routes For regexps like your example see: blog.rjzaworski/2011/12/regex-routing-with-backbone-js/ Try out the todo example on meteor, see the client/todo.js file:

////////// Tracking selected list in URL ////////// var TodosRouter = Backbone.Router.extend({ routes: { "todo_list/:list_id": "main" }, main: function (list_id) { Session.set("list_id", list_id); Session.set("tag_filter", null); }, setList: function (list_id) { this.navigate("todo_list/"+list_id, true); } }); Router = new TodosRouter; Meteor.startup(function () { Backbone.history.start({pushState: true}); });

更多推荐

如何创建动态URL与流星?

本文发布于:2023-11-12 19:59:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582400.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:流星   动态   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!