We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
微信小程序
小程序基础库: 2.13.0 使用框架: React
import raf from 'raf'; raf.cancal() //可重现。
与raf库不冲突,可正常使用raf.cancel
raf.cancal(); //Illegal invocation
Taro CLI 3.0.11 environment info: System: OS: macOS 10.14.6 Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node Yarn: 1.22.5 - ~/.nvm/versions/node/v10.15.3/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm npmPackages: babel-preset-taro: ^3.0.11 => 3.0.13
分析原因是因为在非h5版本中,raf内部通过@tarojs/runtime的window获取到cancelAnimationFrame为clearTimeout,因为raf使用了caf.apply(window, arguments)实现cancel方法,而这时的window缺失clearTimeout的引用,造成Illegal invocation。
if (process.env.TARO_ENV !== 'h5') { (window as any).requestAnimationFrame = raf; (window as any).cancelAnimationFrame = caf; (window as any).Date = Date; (window as any).setTimeout = setTimeout }
module.exports.cancel = function() { caf.apply(root, arguments) }
The text was updated successfully, but these errors were encountered:
可以直接从 @tarojs/runtime 里引入 requestAnimationFrame 来使用
Sorry, something went wrong.
自己使用raf有兼容问题可以换个方式,只是目前使用的另一个第三方的东西内部使用到了raf,现在来说Taro和这个第三方的东西都是外部的,出现了raf的不兼容,这样就不好办了。我目前使用alias覆盖了raf的引入倒是暂时解决了,不过这个兼容问题看能不能官方兼容一下
fix(runtime): 在微信中clearTimeout要绑定global,fix #7749
3208e3c
3408af3
Successfully merging a pull request may close this issue.
相关平台
微信小程序
小程序基础库: 2.13.0
使用框架: React
复现步骤
期望结果
与raf库不冲突,可正常使用raf.cancel
实际结果
raf.cancal(); //Illegal invocation
环境信息
补充信息
分析原因是因为在非h5版本中,raf内部通过@tarojs/runtime的window获取到cancelAnimationFrame为clearTimeout,因为raf使用了caf.apply(window, arguments)实现cancel方法,而这时的window缺失clearTimeout的引用,造成Illegal invocation。
代码源头:
taro/packages/taro-runtime/src/bom/window.ts
raf/index.js
The text was updated successfully, but these errors were encountered: