简单的ContainerView导致“不再支持使用defaultContainer”。 [英] Simple ContainerView causes "Using the defaultContainer is no longer supported."

查看:116
本文介绍了简单的ContainerView导致“不再支持使用defaultContainer”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


DEPRECATION:不再支持使用defaultContainer。 [defaultContainer#lookup]请参阅: http://git.io/EKPpnA


我想这与我将视图附加到控制器的方式有关,



请注意,如果子视图中的模板被内联编译,错误不会发生,只有在向视图的模板属性提供外部模板时才会发生。



http://jsbin.com/uqawux/2/edit



谢谢

解决方案

这个弃用消息引用这个 gist ,如果您查看迁移路径:(WIP)部分,则它具有以下文本:



< blockquote>

如果您在parentView的上下文之外创建视图(这个
可能不被推荐,但是正在发生),您将需要使
确保inst




  this.container.lookup('view:apple ')
//将提供一个苹果视图的实例。

所以,您需要更新代码以使用容器而不是 App。 FooView.create()

  App.IndexController = Ember.Controller.extend({
show:function(){
var v = this.container.lookup('view:foo');
v.appendTo(App.rootElement);
}
});

根据您的版本,您将收到一条新的警告消息:


DEPRECATION:直接在控制器上实现的动作处理程序是
,不赞成使用操作对象上的操作处理程序(在
上显示)


在这种情况下,将您的操作放在操作 object:

  App.IndexController = Ember.Controller.extend({
actions:{
显示:function(){
var v = this.container.lookup('view:foo');
v.appendTo(App.rootElement);
}
}
});

这是一个更新的jsbin,使用最新的没有警告的ember版本 http://jsbin.com/uqawux/4/edit


With latest Ember, the following simple ContainerView causes the error:

DEPRECATION: Using the defaultContainer is no longer supported. [defaultContainer#lookup] see: http://git.io/EKPpnA

I guess this is somehow related to the way I append the view into the controller,

Please note that if template in the sub views are compiled inline the error doesn't happen, it only happens when providing external template to the 'template' property of the view.

http://jsbin.com/uqawux/2/edit

Thanks

解决方案

That deprecation message reference this gist, if you look the migration paths: (WIP) section, it have the following text:

if you are creating views outside the context of a parentView (this may not be recommended, but it is happening) you will want to make sure to instantiate your view via the container itself.

this.container.lookup('view:apple')
// will provide a instance of apple view.

So you need to update your code to use the container instead of App.FooView.create().

App.IndexController = Ember.Controller.extend({
  show: function() {    
    var v = this.container.lookup('view:foo');    
    v.appendTo(App.rootElement);
  }
});

Depending of your version, you will receive a new warning message:

DEPRECATION: Action handlers implemented directly on controllers are deprecated in favor of action handlers on an actions object (show on )

In that case put your action in a actions object:

App.IndexController = Ember.Controller.extend({
  actions: {
    show: function() {    
      var v = this.container.lookup('view:foo');    
      v.appendTo(App.rootElement);
    }
  }  
});

This is a updated jsbin using the lastest ember version without warnings http://jsbin.com/uqawux/4/edit

这篇关于简单的ContainerView导致“不再支持使用defaultContainer”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆