Closed 531431988 closed 5 years ago
@531431988 用的是wepy版本还是原生的版本?
@531431988 复现了你的问题,正在解决中。先提供个临时解决方案:可以先清空下数据,然后再更新,类似这样:
this.setData({
items: []
}, () => {
let newArr = [...items]
newArr.splice(index, 1)
this.setData({
items: newArr
})
})
@531431988 另外一个比较好的解决方案: swipeout 组件内加个 reset 方法,先手动加一下,下个版本会更新上去:
reset () {
return new Promise((resolve, reject) => {
this.setData({
left: 0,
startX: ''
}, () => {
resolve()
})
})
}
然后页面上,先调用组件的 reset 方法,再更新数组:
const swipeCtx = this.selectComponent('#swipe-' + index)
swipeCtx.reset().then(res => {
const newArr = [...items]
newArr.splice(index, 1)
this.setData({
items: newArr
})
})
@531431988 该问题是小程序组件bug导致的,你可以使用上述两个方案解决
好的,感谢
求个demo
@531431988 不要放到onLoad函数内调用该函数,你要在你执行了删除之后在删除数组之前执行该逻辑
@531431988 给你提供一个例子 page-js page-wxml 找到kai-ui/swipeout/index.js新增一个方法
我用wepy框架写的,一直取不到ID
试了无数次,依然取不到 也看是文档说需要usingComponents引入,确实也是这样引入的 this.$wxpage.selectComponent(id or class) 在wepy里面一直都取不到
@531431988 可能你的wepy版本不兼容usingComponents吧,关于这个我没法帮到你,你可以去wepy社区寻求下帮助
好的,谢谢大佬
删除前
删除后
为何后面的自动展开操作按钮?怎么取消展开操作