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

Canvas 无法绘制 #7444

Closed
GreatAuk opened this issue Aug 26, 2020 · 6 comments
Closed

Canvas 无法绘制 #7444

GreatAuk opened this issue Aug 26, 2020 · 6 comments
Assignees
Labels
duplicate This issue or pull request already exists F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@GreatAuk
Copy link

GreatAuk commented Aug 26, 2020

相关平台

微信小程序

小程序基础库: 2.12.0
使用框架: React

复现步骤

componentDidMount () {
  let ctx = Taro.createCanvasContext('myCanvas', this.$scope);
  ctx.setFillStyle('red');
  ctx.fillRect(50,50,200,200);
  ctx.draw()
}
<Canvas
id='myCanvas'
canvasId='myCanvas'
style={{width: '100%', height: 400}}
type='2d'
>
</Canvas>

还有一个问题就是 导出图片报错
image

    ctx.draw(false, Taro.canvasToTempFilePath({
      canvasId: 'myCanvas',
      success: res => {
        console.log(res.tempFilePath)
      }
    },this.$scope))

期望结果

显示一个长方形

实际结果

空白

环境信息

Taro CLI 3.0.7 environment info:
    System:
      OS: macOS 10.14.5
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.16.1 - /usr/local/bin/node
      Yarn: 1.19.1 - /usr/local/bin/yarn
      npm: 6.13.4 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 3.0.7 => 3.0.7 
      @tarojs/mini-runner: 3.0.7 => 3.0.7 
      @tarojs/react: 3.0.7 => 3.0.7 
      @tarojs/runtime: 3.0.7 => 3.0.7 
      @tarojs/taro: 3.0.7 => 3.0.7 
      @tarojs/webpack-runner: 3.0.7 => 3.0.7 
      babel-preset-taro: 3.0.7 => 3.0.7 
      eslint-config-taro: 3.0.7 => 3.0.7 
      nervjs: ^1.5.7 => 1.5.7 
      react: 16.8.2 => 16.8.2 
      taro-ui: ^3.0.0-alpha.3 => 3.0.0-alpha.3 
    npmGlobalPackages:
      typescript: 3.1.1

补充信息

这是个重大bug,希望能尽快修复

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Aug 26, 2020
@GreatAuk GreatAuk changed the title Cancas 无法绘制 Canvas 无法绘制 Aug 26, 2020
@baranwang
Copy link
Contributor

ctx.draw 不适用 type=2d,新版本默认给了一个 type=2d 可以设置 type=''

@GreatAuk
Copy link
Author

@baranwang 所以这算 bug 吗? draw 是 canvas 必要的方法吧

@luckyadam luckyadam self-assigned this Aug 27, 2020
@luckyadam luckyadam added this to the 3.0.9 milestone Aug 27, 2020
@Chen-jj Chen-jj added the duplicate This issue or pull request already exists label Aug 28, 2020
@Chen-jj Chen-jj removed this from the 3.0.9 milestone Aug 28, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Aug 28, 2020

duplicated #7314

@jlala
Copy link

jlala commented Nov 17, 2020

去掉 type='2d' 好了

@zhangjiawei1998
Copy link

什么垃圾玩意

@zhangjiawei1998
Copy link

找了一天Bug, 原来是官方问题,taro文档里都没写这个问题,直接给了一串代码,发现画出来是空白之后,根本摸不着头脑

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

6 participants