我在使用iron-ajax在triblock-table中填充数据时遇到问题。
我的empleelist.json文件位于.html文件所在的文件夹中。而且,当我调试它然后我找到了URL:
http://XXXX:port/p/components/r/en-US/l/tut-people/employeelist.json在此之后,我得到的值是json。
我称之为:
case parameter
when 'dim1' then dim1
.
.
end
但是,我无法在表格中填充数据。
JSON文件:
<link rel="import" href="../triblock-table/triblock-table.html">
<link rel="import" href="../iron-ajax/iron-ajax.html">
<link rel="import" href="../iron-icon/iron-icon.html">
<link rel="import" href="../iron-icons/iron-icons.html">
<link rel="import" href="../paper-listbox/paper-listbox.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-item/paper-icon-item.html">
<link rel="import" href="../paper-item/paper-item-body.html">
<dom-module id="tut-person">
<style is="custom-style">
#table1 {
color: white;
--triblock-table-header-background-color: violet;
--triblock-table-header-color: green;
--triblock-table-even-row-background-color: rgb(80, 80, 80);
--triblock-table-odd-row-background-color: rgb(40, 40, 40);
--triblock-table-row-hover-background-color: darkblue;
}
</style>
<template>
<h1>Table Layout</h1>
<iron-ajax url="employeelist.json" handle-as="json" last-response="{{employees}}" content-type="application/json" auto></iron-ajax>
<triblock-table id="table1" data="{{employees}}" style="width:100%; height:250px;">
<triblock-table-column title="Employee ID" property="id"></triblock-table-column>
<triblock-table-column title="Name" property="Name"></triblock-table-column>
<triblock-table-column title="First Name" property="First Name"></triblock-table-column>
<triblock-table-column title="Last Name" property="Last Name"></triblock-table-column>
<triblock-table-column title="Status" property="Status"></triblock-table-column>
</triblock-table>
</template>
</dom-module>
<script>
Polymer({
is: "tut-person",
behaviors: [TriPlatViewBehavior]
});
</script>
答案 0 :(得分:0)
我能解决这个问题。这是因为json字符串为null。反过来,last-response变量设置为null,因此我在屏幕上没有响应。在纠正了Json字符串后,这很有效。