data数据读取问题?

小程序 文章 2021-03-12 13:01 63 0 全屏看文

data数据读取问题?Data reading problem?

data数据读取问题?

在小程序开发中设置了数据data数据如下:

[{"id":"1","User_name":"u5f20u5b89","User_age":"18","User_addr":"u4e0au6d77u5e02"},{"id":"2","User_name":"u738bu4f4d","User_age":"32","User_addr":"u5929u6d25u5e02"},{"id":"3","User_name":"u674eu56db","User_age":"28","User_addr":"u5317u4eacu5e02"}]

通过代码如下,

结果:

请教这个问题如何解决,感谢。


In the development of the small program, the data is set as follows: [{"Id": "1", "user"_ name":"u5f20u5b89","User_ age":"18","User_ addr":"u4e0au6d77u5e02"},{"id":"2","User_ name":"u738bu4f4d","User_ age":"32","User_ addr":"u5929u6d25u5e02"},{"id":"3","User_ name":"u674eu56db","User_ age":"28","User_ Addr ":" - u5317 - u4eac - u5e02 "}] through the code as follows, the result: ask how to solve this problem, thank you.

回答:

默垂眸:
{{data}} 换成 {{item.id}} 渲染的就是每一项的id 以此类推
黑夜白昼:

<view>

这里面的 {{data}} 改为 {{item.id}} {{item.User_name}} {{item.xxxx}}

</view>

聂政:

wx:for 会循环对应的数组对象,就是你这里的data,你直接在循环内部使用data就会直接显示data,按照数据看应该是想展示数组中对应的信息,wx:for遍历出的对象默认就是item,直接使用item.User_name 或item.User_age,就可以直接获取到想要展示的数据;至于这个item为什么叫‘item’可以看官方文档。

-EOF-