我有一个数组,我想迭代并使用polymer1.0
导入Href
作为calback函数。到目前为止,它仍在工作,但调用数组10x中的每个元素。
这是我的代码
var widgets = Object.keys(e.detail.response); //["pl-left-drawer", "pl-logo", "pl-site-title", "pl-layout-switch", "pl-search", "pl-messages", "pl-alerts", "pl-tasks", "pl-settings", "pl-right-drawer"]
var total = widgets.length;
console.log(widgets);
for (var i=0; i < total; i++) {
Polymer.Base.importHref('/themes/components/custom_components/'+ widgets[i] + '/'+ widgets[i] +'.html', function(e) {
// e.target.import is the import document.
console.log(e.target.import + 'has been imported');
}, function(e) {
console.log(e.target.import + 'has not been imported');
});
}