react提示框几秒_react项目中实现悬浮(hover)在按钮上时在旁边显示提示

.device-icon{width:24px;height:24px;outline:none;cursor:pointer;margin-right:11px;position:relative;&:nth-last-child(2) {

margin-right: 24px;

}}

.camera-icon{background:url('~ROOT/shared/assets/image/vn-screen-camera-off-66-66.png') no-repeat center;background-size:22px 22px;&.camera-icon-hover-show-intro {

&:hover:after {

box-sizing: border-box;height:24px;line-height:24px;position:absolute;bottom:-26px;border-radius:12px;background-color:#ffffff;font-size:12px;color:#626e80;font-style:normal;cursor:default;text-align:center;content:attr(labeltooltip);width:58px;left:-20px;

}}

&.active{background:url('~ROOT/shared/assets/image/vn-camera-hover-69-66.png') no-repeat center;background-size:23px 22px;

}}

.mic-icon{background:url('~ROOT/shared/assets/image/vn-screen-voice-on-54-72.png') no-repeat center;background-size:18px 24px;&.mic-icon-hover-show-intro {

&:hover:after {

box-sizing: border-box;height:24px;line-height:24px;position:absolute;bottom:-26px;border-radius:12px;background-color:#ffffff;font-size:12px;color:#626e80;font-style:normal;cursor:default;text-align:center;content:attr(labeltooltip);width:58px;left:-20px;

}}

&.active{background:url('~ROOT/shared/assets/image/vn-mic-hover-54-72.png') no-repeat center;background-size:18px 24px;

}}

.speaker-icon{background:url('~ROOT/shared/assets/image/vn-screen-speaker-60-66.png') no-repeat center;background-size:20px 22px;

}.wifi-icon{background:url('~ROOT/shared/assets/image/vn-screen-wifi-72-57.png') no-repeat center;background-size:24px 19px;&.wifi-icon-hover-show-intro {

&:hover:after {

box-sizing: border-box;height:24px;line-height:24px;position:absolute;bottom:-26px;border-radius:12px;background-color:#ffffff;font-size:12px;color:#626e80;font-style:normal;cursor:default;text-align:center;content:attr(labeltooltip);width:58px;left:-20px;

}}

&.active{background:url('~ROOT/shared/assets/image/vn-wifi-72-72.png') no-repeat center;background-size:24px 24px;

}}

.restart-icon{background:url('~ROOT/shared/assets/image/vn-screen-restart-60-60.png') no-repeat center;background-size:19px 19px;

}.exit-icon{background:url('~ROOT/shared/assets/image/vn-screen-exit-60-60.png') no-repeat center;background-size:19px 19px;&.exit-icon-hover-show-intro {

&:hover:after {

box-sizing: border-box;height:24px;line-height:24px;position:absolute;bottom:-26px;border-radius:12px;background-color:#ffffff;font-size:12px;color:#626e80;font-style:normal;cursor:default;text-align:center;content:attr(labeltooltip);width:95px;left:-35px;

}}

&.active{background:url('~ROOT/shared/assets/image/screen-exit-blue-60-60.png') no-repeat center;background-size:19px 19px;

}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在React实现图形验证码,可以使用第三方库react-captcha来生成验证码。首先,需要在项目安装react-captcha。 ``` npm install react-captcha --save ``` 然后,在组件使用Captcha组件来生成验证码。在这个组件,我们可以设置一些属性,例如验证码长度、字符集、背景颜色等等。在这个例子,我们将生成一个长度为6的验证码,字符集为大小写字母和数字,背景颜色为浅灰色。 ``` import React from 'react'; import Captcha from 'react-captcha'; class CaptchaExample extends React.Component { render() { return ( <Captcha captchaCodeLength={6} captchaChars={'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'} captchaBgColor={'#f2f2f2'} /> ); } } export default CaptchaExample; ``` 此时,我们已经能够在React生成图形验证码了。但是,我们还需要在验证码输入框验证用户输入是否正确。这可以通过在Captcha组件上设置onVerify属性来实现。 ``` import React from 'react'; import Captcha from 'react-captcha'; class CaptchaExample extends React.Component { constructor(props) { super(props); this.state = { captchaCode: '', validCaptcha: '' }; } handleVerify = code => { this.setState({ validCaptcha: code }); }; handleSubmit = e => { e.preventDefault(); if (this.state.captchaCode === this.state.validCaptcha) { alert('验证码正确!'); } else { alert('验证码错误!'); } }; handleChange = e => { this.setState({ captchaCode: e.target.value }); }; render() { return ( <form onSubmit={this.handleSubmit}> <Captcha captchaCodeLength={6} captchaChars={'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'} captchaBgColor={'#f2f2f2'} onVerify={this.handleVerify} /> <input type="text" value={this.state.captchaCode} onChange={this.handleChange} /> <button type="submit">提交</button> </form> ); } } export default CaptchaExample; ``` 在这个例子,我们在Captcha组件上设置了onVerify属性,当用户输入验证码时,会自动调用handleVerify方法,将生成的验证码存储在validCaptcha状态。当用户提交表单时,将会比较用户输入的验证码和生成的验证码是否一致。如果一致,则弹出“验证码正确!”的提示框,否则弹出“验证码错误!”的提示框。 这样,我们就完成了在React生成图形验证码的过程。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值