Backbone.js - 如何从url参数中检索并将其显示在页面上

问题描述:

我正在为我的移动应用程序项目使用backbone.js。我的问题是,我如何从url参数获得价值,然后在页面上显示?Backbone.js - 如何从url参数中检索并将其显示在页面上

JS

define(['jquery', 'underscore', 'backbone','text!templates/attribute/attributeValueIndexTemplate.html'], function($, _, Backbone,attributeValueIndexTemplate) { 
    var AttributeValueIndexView = Backbone.View.extend({ 
     el: $("#page"), 
     initialize: function() { 
      this.$el.off(); 
     }, 
     render: function(attributeId) { 
      this.$el.html(attributeValueIndexTemplate); 
     } 
    }); 
    return AttributeValueIndexView; 
}); 

对于这一点,您通常使用的路由器和响应路由事件,传递解析URL参数。见http://adrianmejia.com/blog/2012/09/13/backbone-js-for-absolute-beginners-getting-started-part-4/

请注意,您还可以访问URL参数“手动”使用window.location.search但就是不做骨干的最佳途径。