我尝试使用此代码创建元素
<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="../../bower_components/paper-submenu/paper-submenu.html">
<link rel="import" href="../../bower_components/paper-item/paper-item.html">
<link rel="import" href="../../bower_components/paper-menu/paper-menu.html">
<dom-module id="side-menu-element">
<template>
<style></style>
<iron-ajax id="iron-ajax" auto url="side-menu-element-data-en.json" handle-as="json" last-response="{{handleResponse}}"></iron-ajax>
<template is="dom-repeat" items="{{handleResponse.menus}}" as="menu">
<paper-submenu label="[[menu.name]]">
<paper-item class="menu-trigger">[[menu.name]]</paper-item>
<paper-menu class="menu-content sublist2">
<template is="dom-repeat" items="[[menu.items]]" as="in-depth-menu">
<paper-item class="leaf">
<a href="[[in-depth-menu.address]]" title="[[in-depth-menu.topic]]">[[in-depth-menu.topic]]</a>
</paper-item>
</template>
</paper-menu>
</paper-submenu>
</template>
</template>
<script>
(function() {
'use strict';
Polymer({
is: 'side-menu-element',
properties: {
}
});
})();
</script>
</dom-module>
它只是在检查器中显示模板元素,如下所示
<template is="dom-repeat" class="style-scope side-menu-element"></template>
它假设从json文件中获取葡萄数据并将其注入纸张子菜单,纸张菜单和纸张项目。在文档中没有对json文件中的iron-ajax元素检索的数据进行操作,只是将其绑定到其他元素