我请求成功了,js是这样的
this .data.searchResults = [ {id: 11, name: '张三' }, {id: 22, name: '李四' } ]; |
xwml是这么写的
< view wx:for-items = "{{searchResults}}" wx:key = "result" > < view class = "items" > < p >{{result.id}} --- {{result.name}}</ p > </ view > </ view > |
以上代码运行后,什么都没输出,请问是什么问题啊
<
view
wx:for-items
=
"{{searchResults}}"
wx:key
=
"id"
>
<
view
class
=
"items"
>
<
p
>{{item.id}} --- {{item.name}}</
p
>
</
view
>
</
view
>
解决了,regular用习惯了,本来是
this
.setData({
searchResults: xxxx
});
我写成了
this
.data.searchResults = xxx;
<
block
wx:for-items
=
"{{searchResults}}"
wx:for-item
=
"result"
>
<
view
class
=
"items"
>
<
view
class
=
"item"
>
<
text
>{{result.id}} --- {{result.name}}</
text
>
</
view
>
</
view
>
</
block
>
改成这样似乎也没用。。。。。