-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Taro hook 组件中怎么获取当前组件的实列? #4521
Comments
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
我感觉是不是加上一个hook就可以? |
但是目前没有这个 |
暂时写 this.$scope |
这里有个 Taro 工具库已实现 useScope: https://github.com/fjc0k/vtils/tree/master/packages/taro#usescope |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题描述
在使用
canvas
的createCanvasContext
方法时,需要传入一个当前组件的实列;使用hook,是获取不到当前组件的
this
,那么我们在使用createCanvasContext
方法第二个参数传递什么呢?例:
const context: Taro.CanvasContext = Taro.createCanvasContext('poster-canvas', this);
,这里传入的
this
是获取不到的。复现步骤
期望行为
[这里请用简洁清晰的语言描述你期望的行为]
报错信息
[这里请贴上你的完整报错截图或文字]
系统信息
👽 Taro v1.3.18
Taro CLI 1.3.18 environment info:
System:
OS: macOS 10.14.6
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.9.1 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
npmPackages:
@tarojs/components: 1.3.18 => 1.3.18
@tarojs/plugin-babel: 1.3.18 => 1.3.18
@tarojs/plugin-csso: 1.3.18 => 1.3.18
@tarojs/plugin-less: 1.3.18 => 1.3.18
@tarojs/plugin-uglifyjs: 1.3.18 => 1.3.18
@tarojs/rn-runner: 1.3.18 => 1.3.18
@tarojs/router: 1.3.18 => 1.3.18
@tarojs/taro: 1.3.18 => 1.3.18
@tarojs/taro-alipay: 1.3.18 => 1.3.18
@tarojs/taro-h5: 1.3.18 => 1.3.18
@tarojs/taro-swan: 1.3.18 => 1.3.18
@tarojs/taro-tt: 1.3.18 => 1.3.18
@tarojs/taro-weapp: 1.3.18 => 1.3.18
@tarojs/webpack-runner: 1.3.18 => 1.3.18
eslint-config-taro: 1.3.18 => 1.3.18
eslint-plugin-taro: 1.3.18 => 1.3.18
nerv-devtools: ^1.4.4 => 1.4.4
nervjs: ^1.4.4 => 1.4.4
stylelint-config-taro-rn: 1.3.18 => 1.3.18
stylelint-taro-rn: 1.3.18 => 1.3.18
npmGlobalPackages:
typescript: 3.5.1
补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]
The text was updated successfully, but these errors were encountered: