【发布时间】:2019-05-06 23:17:35
【问题描述】:
json array localstorage format
您好,我正在开发一个 ionic 应用程序。我是 Ionic 和 Typescript 的新手。
正如您在下图中看到的,我正在从 API 解析我的 json 数组中的数据。
在 ts 文件上我正在编写这段代码
` 公共类别详细信息:任何;
const datacat = JSON.parse(localStorage.getItem('categoryData')); this.categoryDetails = datacat.categoryData;`
当我写这个时在我的html文件中
<h1 class="business-top">Business of the category {{categoryDetails.name}}</h1>
我收到错误消息“TypeError: Cannot read property 'name' of undefined”
我知道我没有正确读取属性“名称”。我该怎么做?
此外,如何显示与类别的特定 term_id 关联的企业?
【问题讨论】:
标签: arrays json typescript ionic3