gpt4 book ai didi

javascript - 如何隐藏打开键盘上的 float 按钮(Android/iOS)?

转载 作者:行者123 更新时间:2023-12-02 21:37:39 25 4
gpt4 key购买 nike

我的网站上有一个 float 按钮,它是用 Reactjs 构建的。每当我在手机上打开键盘时,我想隐藏该按钮。

最佳答案

当某些输入获得焦点时,键盘会打开。所以你可以用onFocus事件来处理它

onFocus = () => {
this.setState({hiddenButton: true})
}
onBlur = () => {
this.setState({hiddenButton: false})
}

render() {
<React.Fragment>
{!this.state.hiddenButton ? <button>Click here</button> : null }
<input
type='text'
onFocus={ this.onFocus }
onBlur={ this.onBlur }
placeholder="Enter your text here."
/>
<React.Fragment>
}

onBlur 事件在您离开输入时触发

希望这对你有帮助

关于javascript - 如何隐藏打开键盘上的 float 按钮(Android/iOS)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60451858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com