-
Notifications
You must be signed in to change notification settings - Fork 927
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
小程序引用老虎机组件报错 #313
Comments
我都服了, 你看不到代码块的开始和结束吗, 这也能放歪? |
问题不大 咋回事老哥 |
问题很大, 你重新编辑一下, 这代码都扭曲到一起了怎么看 |
|
顺便提供taro的版本信息, 小程序基准库, 最好是发个能复现问题的demo |
|
你这代码写的是什么?你在箭头函数里使用this?你在搞笑? |
嗯? 还报错? 奇怪 |
说一下你taro的版本和小程序基准库的版本 |
"dependencies": { |
排查完毕, 但是这种数字的方式也可以支持一下, 今晚会发个新版兼容一下 |
你当前是什么框架(必填):taro
你使用的是哪个包(必填):"@lucky-canvas/taro"
你当前插件的版本(必填): "^0.0.12",
当前环境是小程序还是浏览器(选填):taro
详细描述你的bug:
小程序引用老虎机组件报错
export default SlotMachiner;
// 代码开始, 别再放歪了行吗
import React, { Component } from 'react';
import { SlotMachine } from '@lucky-canvas/taro/react'
import { View } from '@tarojs/components';
class SlotMachiner extends Component {
myLucky: any
constructor(props) {
super(props);
this.myLucky = React.createRef()
}
playGame = () => {
this.myLucky.current.play()
setTimeout(() => {
// 假设 4 种结果
const res = [
[9, 9, 6],
[0, 0, 7],
[6, 6, 6],
[8, 8, 8]
]
// 随机取一组数据
const index = res[Math.random() * 4 >> 0]
// 调用 stop 方法停止游戏
this.myLucky.current.stop(index)
}, 500);
}
render() {
return (
<>
<SlotMachine
ref={this.myLucky}
width={240}
height={180}
blocks={[
{ padding: '10px', background: '#617df2' },
{ padding: '10px', background: '#869cfa' },
{ padding: '10px', background: '#afc8ff' },
{ padding: '10px', background: '#e9e8fe' },
]}
>
<View onClick={() => this.playGame()}>开始抽奖
</>
);
}
}
export default SlotMachiner;
// 代码结束
The text was updated successfully, but these errors were encountered: