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

为什么需要传入 page 和 name? #28

Closed
FrankFang opened this issue May 24, 2018 · 2 comments
Closed

为什么需要传入 page 和 name? #28

FrankFang opened this issue May 24, 2018 · 2 comments

Comments

@FrankFang
Copy link

目前的用法

        wemark.parse(task.description, this, {name: 'wemark'})

为什么不做成这样

     this.setDate({wemark: wemark.parse(task.description) })

请问是处于什么目的要把 API 设计得这么奇怪?

@FrankFang
Copy link
Author

看了一下 wemark 的结构,大概了解了

@TooBug
Copy link
Owner

TooBug commented May 24, 2018

这里主要是历史原因了,之前微信小程序没有图片自适应高度的功能,因此需要在图片加载后动态去调整它的高度。而因为小程序的wxml只能访问page实例的data,因此这里存在需要动态修改data的情况,于是wemark就只能拿着page实例。

后来小程序支持了图片自适应高度,wemark代码也做了改变,把这个逻辑去掉了。参考这次提交:

fddb928

按目前的实现,API可以设计成你说的这样,但是考虑到向下兼容,就没做这个改动。

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