简体   繁体   English

Backbone Router ...如何处理url

[英]Backbone Router… how to deal with url

I have an application which main files look like these (1), (2), (3). 我有一个应用程序,主要文件看起来像这些(1),(2),(3)。

The Backbone.Router works fine in this case (because it triggers #page ): Backbone.Router在这种情况下工作正常(因为它触发#page ):

http://localhost/index.php#page

How should I configure it if the url is the following (in order to trigger /some#page ): 如果网址如下,我该如何配置它(为了触发/some#page ):

http://localhost/index.php/some#page

PS: PS:
the backend of this web app is using Synfony2 这个网络应用程序的后端正在使用Synfony2


(1) (1)

// index.php
<script data-main='mainApp.js' src='require.js'>

(2) (2)

// mainApp.js
define([
  'js/router'
], function(Router) {
    "use strict";
    var initialize = function ()
    {
            Router.initialize();
    }

    return {
        initialize: initialize
    };
});

(3) (3)

// router.js
define([
    'myView'
], function(MyView){
    console.log(MyView)
    var AppRouter = Backbone.Router.extend({
        routes: {
           'page' : 'view'
        },

        view: function () {
          //some code
        }
    });
});

Does this work? 这有用吗?

routes: { 
   '/some:page': 'view',
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM