【发布时间】:2019-09-01 07:02:41
【问题描述】:
源代码在这里:https://codesandbox.io/s/hony-quekr
按钮本身是一个span 元素。这里是相关代码sn-p。
import React, { Component } from "react";
import posed from "react-pose";
import "./Choice.css";
const config = {
visible: {
opacity: 1,
y: 0,
delay: 100
},
hidden: {
opacity: 0,
y: 8,
delay: 200,
transition: {
duration: 200
}
}
};
const Underline = posed.div(config);
class Choice extends Component {
constructor() {
super();
this.state = {
isVisible: false
};
}
componentDidMount() {
this.setState({ isVisible: this.props.visibility });
}
componentDidUpdate(prevProps) {
if (this.props !== prevProps) {
this.setState({ isVisible: this.props.visibility });
}
}
render() {
return (
<span
className="word"
onMouseEnter={() => this.props.onMouseEnter()}
onMouseLeave={() => this.props.onMouseLeave()}
onClick={() => this.props.onClick()}
>
{this.props.name}
<Underline
className="underline"
pose={this.state.isVisible ? "visible" : "hidden"}
/>
</span>
);
}
}
问题出在移动设备上,当在移动设备上查看页面时,单击(轻按)每个按钮时都会出现一个黑色区域。我附上了一张图片来演示。
我想摆脱这些黑暗区域,这样当你点击这些按钮时除了显示下划线之外什么都不会发生
【问题讨论】:
-
您的演示在我的 iPhone 上运行良好。正如预期的那样,没有点击文本选择。
标签: javascript html css reactjs