遍历的时候筛选IsUse为true的数据,我这么写问题在哪?为什么加上以后页面上一条数据都没有,去掉filter就有数据了
加上filter
<tr v-for="(item,index) in roadList.filter(obj=>{obj.IsUse==true})" :key="index">
<td>{{item.RouteName}}</td>
<td>{{item.CodeType}}</td>
<td>{{item.PointCodeStartId}}</td>
<td>{{item.CodeFirStart}}</td>
<td>{{item.CodeIcaoStart}}</td>
<td>{{item.PointCodeEndId}}</td>
<td>{{item.CodeFirEnd}}</td>
<td>{{item.CodeIcaoEnd }}</td>
<td>{{item.DirecDescription}}</td>
</tr>
去掉filter
<tr v-for="(item,index) in roadList" :key="index">
<td>{{item.RouteName}}</td>
<td>{{item.CodeType}}</td>
<td>{{item.PointCodeStartId}}</td>
<td>{{item.CodeFirStart}}</td>
<td>{{item.CodeIcaoStart}}</td>
<td>{{item.PointCodeEndId}}</td>
<td>{{item.CodeFirEnd}}</td>
<td>{{item.CodeIcaoEnd }}</td>
<td>{{item.DirecDescription}}</td>
</tr>
filter 是需要你把符合标准的规则return回去的...
上面写的
roadList.filter(obj => {return obj.IsUse === true})
和
roadList.filter(obj => obj.IsUse === true)
都可以解决问题