繁体   English   中英

Ember.js中的Google图表呈现

[英]Google chart rendering in Ember.js

嘿,任何人都可以帮我解决这个问题。 我的看法是

<div id="sankey_multiple" style="width: 900px; height: 300px;"></div>

我的Component.js是

App.sankeyComponent = Ember.Component.extend({
    needs: ['sankey'],
    //navigation: Ember.computed.alias('controllers.navigation'),
    isExpandedBookmarks: false,
    didInsertElement: function() {
       alert('insert');
    }
});

但是didInsertElement函数无法正常工作,我无法准确地添加Google图表脚本。

如果我将其添加到init函数中,则表示找不到容器。 所以我认为我们需要在didInsertElement之后添加。 但是它不起作用。 有人可以帮我吗? 先感谢您。

Ember希望组件的命名约定具有大写的字母,因此您应按以下步骤更改组件:

App.SankeyComponent = Ember.Component.extend({
    needs: ['sankey'],
    //navigation: Ember.computed.alias('controllers.navigation'),
    isExpandedBookmarks: false,
    didInsertElement: function() {
       alert('insert');
    }
});

另外,我不确定发布的视图是尝试使用组件的视图还是组件本身的视图。 这些应尽可能设置:

组件的定义:

<script type="text/x-handlebars" id="components/sankey-component ">
    <!-- HTML for your component -->
</script>

在视图中显示组件,如下所示:

{{sankey-component}}

暂无
暂无

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

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