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

支持在Component中调用 #20

Open
SheldonLaw opened this issue May 29, 2018 · 1 comment
Open

支持在Component中调用 #20

SheldonLaw opened this issue May 29, 2018 · 1 comment

Comments

@SheldonLaw
Copy link

需求描述

从小程序基础库版本 1.6.3 开始,小程序支持简洁的组件化编程 - 小程序自定义组件,但在Component中引用weSwiper会出现动画失效的问题。

通过阅读源码发现:

weSwiper通过动态修改view中的animation属性来实现动画效果,数据传递是通过page.setData来实现的。这样就导致了在Component里引用weSwiper时,无法得到更新的animation值来实现动画。

image

具体实现

为了实现在Component中引用weSwiper,添加了context参数,使得数据传递是通过context.setData(这里的context是component)来实现的,具体代码如下:

image

讨论

还有没有别方案实现该需求:通过page.setData来改变page的animation属性,再将page中的animation属性传递给component,实现动画。但是破坏了component的封装性。

欢迎讨论,再次感谢你们贡献了这个优秀的组件!

@liuhuyu
Copy link

liuhuyu commented Aug 19, 2019

非常感谢 用上了

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

No branches or pull requests

2 participants