for循环出的数据,删除其中一条或者多条,怎么才能让页面保持在当前位置,同时删除的这条数据消失?

小程序 文章 2021-03-24 11:21 0 23 全屏看文

for循环出的数据,删除其中一条或者多条,怎么才能让页面保持在当前位置,同时删除的这条数据消失?For the data looped out, delete one or more of them, how can we keep the page at the current position and the deleted data disappear?

for循环出的数据,删除其中一条或者多条,怎么才能让页面保持在当前位置,同时删除的这条数据消失?

第一种办法是点击删除刷新页面重新调用接口,但是因为接口是分页的,所以没办法保持原来的浏览进度(分页每次只查询十条数据)

第二种就是不刷新页面给删除的数据进行隐藏,但是小程序只支持变量赋值的方式来控制隐藏和显示,这样就只能隐藏一条数据,隐藏第二条数据的话,第一条数据就显示出来了

The first method is to click Delete to refresh the page and call the interface again, but because the interface is paginated, it can't keep the original browsing progress (only query ten pieces of data each time in pagination). The second method is not to refresh the page to hide the deleted data, but the applet only supports variable assignment to control the hiding and display, so only one piece of data can be hidden, If the second data is hidden, the first data will be displayed

回答:

跨商通:

在这个数组元素上加个标签:isDeleted:true

Brother斌🎈:

list:[{data:1,hide:false},{data:1,hide:true},{data:1,hide:false},{data:1,hide:true}]

<block wx:for="{{list}}">

<view wx:if="{{!item.hide}}">.....</view>

</block>

叶⃰子⃰:

怎么样用同一个方法,给不同的view设置隐藏状态呢

-EOF-