繁体   English   中英

Ember.js查看和参数

[英]Ember.js View and params

我有一条Ember.js这样的路线:

this.route 'doc', path: '/docs/:doc'

我需要根据:doc param设置模板。 我怎样才能做到这一点?

谢谢。

也许你可以尝试这样的事情:

  1. 在“templateName”属性中将所需的templateName设置到上下文/模型中。
  2. 在路径视图中访问View(=您的模型)的上下文并读取属性并将其设置为View的templateName。

App.DocView = Ember.View.extend({
    render : function(buffer){
      var context = this.get("context.content");
      this.set("templateName", context);
      this._super(buffer);
    }
});

链接到小提琴: http//jsfiddle.net/mavilein/DQ8gS/2/

暂无
暂无

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

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