Skip to content
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

组件中有子组件是列表时,初始值为空在初始化时会报错导致该组件失效问题的解决 #411

Closed
wants to merge 2 commits into from

Conversation

useryu
Copy link

@useryu useryu commented Sep 28, 2017

在官方的例子中, 有一个 “测试组件Repeat" 如果初始值设置为 [] ,会报错。
我本意是,实际工作中,很多列表数据是从后台取的,初始值就是空数组,然后从网络加载。试了下,就发现报错了。看了下错误代码,就试着修复了一下,只是解决了问题,但老实说没看懂原代码,作者有时间可以好好说明下。

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 96.739% when pulling e75e874 on useryu:master into a548fbc on wepyjs:master.

@Gcaufy
Copy link
Collaborator

Gcaufy commented Sep 28, 2017

能给一个报错的示例么?

@useryu
Copy link
Author

useryu commented Sep 29, 2017

就是按 https://wepyjs.github.io/wepy/#/ 指导的创建一个项目后的例子中, 在index.wpy文件中,把 data.groupList 的初始值改为[], 在加载时,就会报空对象错误。 这种情况在开发中是很常见的,初始时,数组是空的,后面再通过AJAX加载数据。

@Gcaufy
Copy link
Collaborator

Gcaufy commented Sep 30, 2017

感谢你的PR,测试过了,这里的确是一个BUG。PR有问题,没能过CI,而且COMMIT也有一些问题,我按照你这个重写一下这里的逻辑。

Gcaufy added a commit that referenced this pull request Sep 30, 2017
@Gcaufy
Copy link
Collaborator

Gcaufy commented Sep 30, 2017

下午看了一下,这个BUG修复起来还没有那么简单,用户在改变list时,还需要通知子组件及时去更新子组件数据。
编译环节和digest环节都有做处理,COMMIT如下,如果看到有什么问题也可以告诉我。fd3fdf2

@Gcaufy Gcaufy closed this Sep 30, 2017
@Gcaufy
Copy link
Collaborator

Gcaufy commented Oct 10, 2017

#410

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants