【问题标题】:Cannot read property 'connectOutlet' of undefined TypeError:无法读取未定义类型错误的属性“connectOutlet”:
【发布时间】:2015-05-14 23:46:26
【问题描述】:

这是我的路线。当我使用来自另一个控制器的 trasitionToRoute 方法调用此路由时,我收到错误消息。

这是我的路由器:

 App.AllSectionsRoute = Ember.Route.extend({

     renderTemplate: function() {
        //this._super(); 

        this.render('fire', { outlet: 'fire', into: 'allSections' });

        this.render('gas', { outlet: 'gas', into: 'allSections' });

    }
});

这是我的模板:

<script type="text/x-handlebars" data-template-name="allSections">
        <hr/>
        <hr/>
        <div class='outletArea'>
            {{outlet "fire"}}
        </div>
        <hr/>
        <div class='outletArea'>
            {{outlet "gas"}}
        </div>
    </script>

如果我不调用this._super(controller, model); 语句,那时我会收到connectOutlet of undefined 的错误。

但是当我调用这个语句时,错误不会出现,但是我必须渲染到模板“allsections”中的“fire”和“gas”这样的额外模板没有被渲染。它将当前模板呈现为“allSections”,但那是已经打开的模板。

如果我错了,请建议我.....

【问题讨论】:

    标签: ember.js ember-router


    【解决方案1】:

    不确定您还在做什么,但我无法重现您的问题。 我创建了这个jsbin 来模拟您的场景,它工作正常。我打电话给this._super()寿:

    App.AllSectionsRoute = Ember.Route.extend({
      renderTemplate: function() {
         this._super();
    
         this.render('fire', {
           into: 'allSections',
           outlet: 'fire'
         });
    
         this.render('gas', {
           into: 'allSections',
           outlet: 'gas'
         });
       }
    });
    

    【讨论】:

    • 你是对的,但是当我调用 this._super() 方法时,在 allSections 模板中呈现当前打开的模板,而不是“gas”和“fire”。感谢您编辑我的语法,并为我糟糕的英语感到抱歉。为什么它是渲染以前的模板而不是气体和火。那是我的问题。
    • “以前的模板”是什么意思?
    • 嗨@MilkyWayJoe 例如,如果我已经打开了gas模板然后我执行这个任务意味着在“allSections”中打开“gas”和“fire”,那时只有“gas”模板会在 allSections 的两个出口中呈现“allSections”
    • 我认为这个错误会导致渲染新模板出现问题,请检查它 EmberError {description: undefined, fileName: undefined, lineNumber: undefined, message: "Assertion Failed: Attempted to register a view with an id already使用中:ID__Plans_undefined81636ff3-f0e4-4556-8cb7-a8f5956801d3",名称:"错误"…}
    • 明显少了一块。您认为您可以编辑该 jsbin 以显示您的场景吗?我试图重现它,但到目前为止,我可能会根据您所描述的内容出错
    猜你喜欢
    • 1970-01-01
    • 2018-04-29
    • 1970-01-01
    • 1970-01-01
    • 2021-12-03
    • 2021-11-22
    • 2017-08-12
    • 2022-12-08
    • 2022-12-01
    相关资源
    最近更新 更多