[英]react-konva Text - onClick does not work on mobile
I'm using react-konva in my webapp and on the desktop browser it works perfectly, but on the mobile browser the onClick
does not work. 我在Web应用程序中使用react-konva,在桌面浏览器上它运行正常,但是在移动浏览器上, onClick
无法正常工作。
<Text key={index} index={index} x={position[0]} y={position[1]} fontSize={unit} width={unit} text={mark} fill={fill} fontFamily={'Helvetica'} align={'center'} onClick={ (event) => { alert("Some text...") }} />
Is there a way to get this to work on mobile or do I need to find a replacement for react-konva text? 有没有办法让它在移动设备上运行,还是需要找到react-konva文本的替代品?
You have to use a special mobile event: onTap
. 您必须使用特殊的移动事件: onTap
。
https://konvajs.github.io/docs/events/Mobile_Events.html https://konvajs.github.io/docs/events/Mobile_Events.html
So in your case just use onClick
and onTap
together. 因此,在您的情况下,只需一起使用onClick
和onTap
。
<Text
{...attrs}
onClick={this.handleClick}
onTap={this.handleClick}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.