1

使用 Ember 1.0.0-rc.1 提供一个简单的示例应用程序:

App = Ember.Application.create({
LOG_TRANSITIONS: true
});

App.ApplicationView = Ember.View.extend({ templateName: 'application' });
App.IndexView  = Ember.View.extend({ 
    template : Ember.Handlebars.compile('Hello new Ember!')
});

http://jsfiddle.net/nL5vf/

IndexView 无法渲染,因为在渲染期间它的视图设置为“未定义”。是故意的吗?

4

1 回答 1

0

It seems like you can't replace the template of any routed view in this fashion. You can do this for other views however.

The following renders nothing:

App = Ember.Application.create();
App.IndexView = Ember.View.extend({
    template: Ember.Handlebars.compile('Hello new Ember!')
});

But this does:

App = Ember.Application.create();
App.MyView = Ember.View.extend({
    template: Ember.Handlebars.compile('Hello new Ember!')
});

(template)

<script type="text/x-handlebars" data-template-name="index">
    {{view App.MyView}}
</script>

I'll have to let someone more qualified weigh in as to whether or not this is intentional.

于 2013-03-05T05:44:04.977 回答