0

我在使用 Iron-ajax 填充三块表中的数据时遇到问题。

我在 .html 文件所在的同一文件夹中有我的 empleelist.json 文件。此外,当我调试它然后我发现 URL :

http://XXXX:port/p/components/r/en-US/l/tut-people/employeelist.json之后,我得到了 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>

但是,我无法在表中填充数据。

JSON文件:

[
    {
"id":123456
"Name":"Kumar Shorav"
"First Name":"Kumar"
"LastName":"Shorav"
"Status":"Active"
    },
{
"id":12346
"Name":"Kumar Shorav1"
"First Name":"Kumar1"
"LastName":"Shorav1"
"Status":"Active"
    }
]
4

1 回答 1

0

我能够解决这个问题。这是因为 json 字符串为空。反过来,last-response 变量设置为 null,所以我在屏幕上没有得到任何响应。更正 Json 字符串后,这是有效的。

于 2018-02-22T20:16:48.927 回答