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

taro3.5.2没渲染 #311

Closed
Pentium286 opened this issue Aug 11, 2022 · 3 comments
Closed

taro3.5.2没渲染 #311

Pentium286 opened this issue Aug 11, 2022 · 3 comments

Comments

@Pentium286
Copy link

  • 你当前是什么框架(必填):taro3.5.2
  • 你使用的是哪个包(必填):官方 npm install @lucky-canvas/taro@latest
  • 你当前插件的版本(必填):"@lucky-canvas/taro": "^0.0.12",
  • 当前环境是小程序还是浏览器(选填):小程序 taro
  • 详细描述你的bug:canvas渲染出来了,但是内容没有显示
    image
  • 问题代码(重要):taro3.5.2初始化以后 src/pages/index/index.tsx 文件下加入以下代码
import React from 'react';
import { View, Text } from '@tarojs/components';
import { LuckyGrid } from '@lucky-canvas/taro/react';
import './index.less';

export default class Index extends React.Component {
  constructor(props) {
    super(props);
    console.log(this);
    this.myLucky = React.createRef();

    this.state = {
      blocks: [{ padding: '13px', background: '#617df2' }],
      prizes: [
        { fonts: [{ text: '0', top: '10%' }], background: '#e9e8fe' },
        { fonts: [{ text: '1', top: '10%' }], background: '#b8c5f2' },
        { fonts: [{ text: '2', top: '10%' }], background: '#e9e8fe' },
        { fonts: [{ text: '3', top: '10%' }], background: '#b8c5f2' },
        { fonts: [{ text: '4', top: '10%' }], background: '#e9e8fe' },
        { fonts: [{ text: '5', top: '10%' }], background: '#b8c5f2' },
      ],
      buttons: [
        { radius: '50px', background: '#617df2' },
        { radius: '45px', background: '#afc8ff' },
        {
          radius: '40px', background: '#869cfa',
          pointer: true,
          fonts: [{ text: '开始\n抽奖', top: '-20px' }]
        },
      ],
    };
  }

  componentWillMount() { }

  componentDidMount() { }

  componentWillUnmount() { }

  componentDidShow() { }

  componentDidHide() { }

  render() {
    const { blocks, prizes, buttons } = this.state;

    return (
      <View className='index'>
        <Text>Hello world!</Text>
        <LuckyGrid
          ref={this.myLucky}
          width="300px"
          height="300px"
          blocks={blocks}
          prizes={prizes}
          buttons={buttons}
          onStart={() => { // 点击抽奖按钮会触发star回调
            // 调用抽奖组件的play方法开始游戏
            this.myLucky.current.play();
            // 模拟调用接口异步抽奖
            setTimeout(() => {
              // 假设后端返回的中奖索引是0
              const index = 0;
              // 调用stop停止旋转并传递中奖索引
              this.myLucky.current.stop(index);
            }, 2500);
          }}
          onEnd={prize => { // 抽奖结束会触发end回调
            console.log(prize);
          }}
        />
      </View>
    );
  }
}
@buuing
Copy link
Owner

buuing commented Aug 11, 2022

??? 什么情况

@buuing
Copy link
Owner

buuing commented Aug 11, 2022

你这配置项也不是九宫格的配置啊, 这不是大转盘的配置吗???

@Pentium286
Copy link
Author

你这配置项也不是九宫格的配置啊, 这不是大转盘的配置吗???

我配置错了😭,所以关闭了。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants