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

taro无法获取 canvas实例 #7575

Closed
luosijie opened this issue Sep 10, 2020 · 5 comments
Closed

taro无法获取 canvas实例 #7575

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

Comments

@luosijie
Copy link

相关平台

微信小程序

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

复现步骤

componentDidMount() {
        const query = wx.createSelectorQuery()
        query
        .select('#myCanvas')
        .fields({ node: true, size: true })
        .exec(res => {
            console.log("my-canvas", res);
        });
    }

render() {
        return (
            <View className="canvas-container">
                <canvas id="myCanvas" type="2d"/>
                <CoverView className="add-image">
                    <CoverImage className="image" src={imageAdd} />
                    <CoverView className="label">添加图片</CoverView>
                </CoverView>
            </View>
        )
    }

期望结果

正常返回一个canvas实例

实际结果

返回的 res 是 [null]]

环境信息

Taro CLI 2.2.7 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.13.0 - /usr/local/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.12.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/components: 2.2.7 => 2.2.7 
      @tarojs/components-qa: 2.2.7 => 2.2.7 
      @tarojs/mini-runner: ^2.2.7 => 2.2.7 
      @tarojs/mobx: 2.2.7 => 2.2.7 
      @tarojs/mobx-h5: 2.2.7 => 2.2.7 
      @tarojs/router: 2.2.7 => 2.2.7 
      @tarojs/taro: 2.2.7 => 2.2.7 
      @tarojs/taro-alipay: 2.2.7 => 2.2.7 
      @tarojs/taro-h5: 2.2.7 => 2.2.7 
      @tarojs/taro-qq: 2.2.7 => 2.2.7 
      @tarojs/taro-quickapp: 2.2.7 => 2.2.7 
      @tarojs/taro-swan: 2.2.7 => 2.2.7 
      @tarojs/taro-tt: 2.2.7 => 2.2.7 
      @tarojs/taro-weapp: 2.2.7 => 2.2.7 
      @tarojs/webpack-runner: 2.2.7 => 2.2.7 
      eslint-config-taro: 2.2.7 => 2.2.7 
      eslint-plugin-taro: 2.2.7 => 2.2.7 
      nerv-devtools: ^1.5.5 => 1.5.7 
      nervjs: ^1.5.5 => 1.5.7 
      stylelint-config-taro-rn: 2.2.7 => 2.2.7 
      stylelint-taro-rn: 2.2.7 => 2.2.7
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Sep 10, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 10, 2020

Duplicate of #7116

@Chen-jj Chen-jj marked this as a duplicate of #7116 Sep 10, 2020
@Chen-jj Chen-jj closed this as completed Sep 10, 2020
@Chen-jj Chen-jj added the duplicate This issue or pull request already exists label Sep 10, 2020
@footya
Copy link

footya commented Oct 21, 2020

遇到了同样的问题Taro 2.2.14

@EricWong1994
Copy link

@footya 朋友,这个问题你最后解决了没有?

@rayallen001
Copy link

<Canvas /> 代替 <canvas/> 试试,当然前提是:

import { Canvas } from '@tarojs/components';

<Canvas id="myCanvas" type="2d"/>

@Johnnnnboy
Copy link

wx换成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