-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
list 组件存在问题 #35
Comments
建议不要使用 array index 来查找组件, 直接使用 key |
并不是通过数组index查找组件的,而是通过指定key: https://github.com/maichong/labrador-demo/blob/master/src/pages/index/index.js#L38 |
我不是指的这个, 我在源码中读到的: list 组件的子组件发起事件时, 事件对象中有个data-path 值, 该值是由 collection name + index 组成的, 例如例子项目中的 “unfinished.0 ” 这个样子, 可是如果array 发生变化以后,组件并没有重绘,于是data-path 也没有改变,导致事件发生的时候出错。 |
你可以用demo项目试试, 增加三个todo ,删除第二个 ,然后点击原来的第三个 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
clone https://github.com/maichong/labrador-demo 以后
,创建几个 todo , check uncheck 几次就能复现.
当 list 组件的数组产生变化时, 子组件在原数组的index 应该变化了, 但是在wxml 中data-path 没有发生相应的改变,
删除中间的2 那条以后. 可以看到原本属于数组第三条的 元素任然保持着data-path = unfinished.2
这就会导致点击事件的时候找不到原来组件
The text was updated successfully, but these errors were encountered: