如何循环出数组中之地当的某一条数据?

小程序 文章 2020-08-10 17:41 591 0 全屏看文

AI助手支持GPT4.0

如何循环出数组中之地当的某一条数据?How to loop out a certain piece of data in the array?

如何循环出数组中之地当的某一条数据?

怎么用wx:for只循环出type为a的数据

How to use Wx: for to only loop out data of type A

回答:

默认²⁰²⁰:
<block wx:for="{{audios}}" wx:key="name">  <view wx:if="{{item.type == 'a'}}">{{item.a}}<view>block>	
夕阳西下?:
<view wx:for="{{audios}}" wx:key="{{item.idex}}">  <view wx:if="{{item.type == 'a'}}">      <view>{{item.name}}view>   view>view>
xplee:

先filter一下或者在wx:for循环里面做判断

const res = audios.filter(function(value, index, array) if ('a' === value.type) {    return true  }})


<view wx:for="audios" wx:key="idex">  <view wx:if="{{item.type == 'a'}}">view>view>
?:

audios[0]

小布师叔:

<block wx:if="{{item.type=='a'}}">block>


-EOF-

AI助手支持GPT4.0