• <legend id='X7X04'><style id='X7X04'><dir id='X7X04'><q id='X7X04'></q></dir></style></legend>

    1. <i id='X7X04'><tr id='X7X04'><dt id='X7X04'><q id='X7X04'><span id='X7X04'><b id='X7X04'><form id='X7X04'><ins id='X7X04'></ins><ul id='X7X04'></ul><sub id='X7X04'></sub></form><legend id='X7X04'></legend><bdo id='X7X04'><pre id='X7X04'><center id='X7X04'></center></pre></bdo></b><th id='X7X04'></th></span></q></dt></tr></i><div id='X7X04'><tfoot id='X7X04'></tfoot><dl id='X7X04'><fieldset id='X7X04'></fieldset></dl></div>

    2. <tfoot id='X7X04'></tfoot>
    3. <small id='X7X04'></small><noframes id='X7X04'>

        <bdo id='X7X04'></bdo><ul id='X7X04'></ul>

        如何将骨干路由器应用于完整路径,而不是哈希

        How to apply backbone router for full path, not a hash(如何将骨干路由器应用于完整路径,而不是哈希)
      1. <tfoot id='MOFBf'></tfoot>
          • <small id='MOFBf'></small><noframes id='MOFBf'>

                <tbody id='MOFBf'></tbody>

                <legend id='MOFBf'><style id='MOFBf'><dir id='MOFBf'><q id='MOFBf'></q></dir></style></legend>
                  <bdo id='MOFBf'></bdo><ul id='MOFBf'></ul>
                • <i id='MOFBf'><tr id='MOFBf'><dt id='MOFBf'><q id='MOFBf'><span id='MOFBf'><b id='MOFBf'><form id='MOFBf'><ins id='MOFBf'></ins><ul id='MOFBf'></ul><sub id='MOFBf'></sub></form><legend id='MOFBf'></legend><bdo id='MOFBf'><pre id='MOFBf'><center id='MOFBf'></center></pre></bdo></b><th id='MOFBf'></th></span></q></dt></tr></i><div id='MOFBf'><tfoot id='MOFBf'></tfoot><dl id='MOFBf'><fieldset id='MOFBf'></fieldset></dl></div>
                  本文介绍了如何将骨干路由器应用于完整路径,而不是哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这种可能性存在吗?我们的网站不是一页的,所有的js文件都压缩在application.js里面,我可以用主干路由器来解析location.path吗?

                  Does that possibility exist? Our site is not one page, but all js-files compressed inside of application.js, can I use backbone router for location.path parsing?

                  我尝试 Backbone.history.start(pushState: true).它对我有用,但它正确吗?我只需要初始解析,而不是通过 Backbone.Router 进行复杂的路由和重定向.

                  I try Backbone.history.start(pushState: true). It works for me, but is it correct? I need just initial parsing, not complicated routes and redirects via Backbone.Router.

                  推荐答案

                  您可以只使用标准路由器.当您实例化它并启动历史对象时,您可以设置它应该用作其基础的根目录.在这种情况下,您似乎想使用 '/'

                  You can just use a standard router. When you instantiate it and start the history object you can set what the root directory it should use as its base. In this case it seems you want to to use '/'

                  var MyRouter = Backbone.Router.extend({
                      routes: {
                          "application/": "somefunc"
                      }
                  }
                  
                  var app = new MyRouter();
                  Backbone.history.start({pushState: true, root: '/'});
                  

                  您需要设置您的网络服务器,以便在您的服务器上调用任何目录时提供您的 HTML 文件(因此骨干网,而不是 Rails,将处理您的路由).

                  You'll need to set your web server to serve up your HTML file whenever any directory is called on your server (so backbone, not rails, will handle your routes).

                  最后,在 HTML 文件中,我有一个在 Dom 就绪上运行的函数,它从 URL 中提取路径并将其传递给 navigate.

                  Finally, in the HTML file I have a function which runs on Dom ready and pulls the path out of the URL and passes it to navigate.

                  var path = location.pathname;
                  app.navigate(path, {trigger: true});
                  

                  这篇关于如何将骨干路由器应用于完整路径,而不是哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  Rails 3.1 ajax:success handling(Rails 3.1 ajax:成功处理)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)

                      <tbody id='RaonM'></tbody>
                    <tfoot id='RaonM'></tfoot>

                    <small id='RaonM'></small><noframes id='RaonM'>

                  1. <i id='RaonM'><tr id='RaonM'><dt id='RaonM'><q id='RaonM'><span id='RaonM'><b id='RaonM'><form id='RaonM'><ins id='RaonM'></ins><ul id='RaonM'></ul><sub id='RaonM'></sub></form><legend id='RaonM'></legend><bdo id='RaonM'><pre id='RaonM'><center id='RaonM'></center></pre></bdo></b><th id='RaonM'></th></span></q></dt></tr></i><div id='RaonM'><tfoot id='RaonM'></tfoot><dl id='RaonM'><fieldset id='RaonM'></fieldset></dl></div>

                    • <bdo id='RaonM'></bdo><ul id='RaonM'></ul>

                      <legend id='RaonM'><style id='RaonM'><dir id='RaonM'><q id='RaonM'></q></dir></style></legend>