我需要知道REACT JS或HTML5中是否有任何API可提供在用户不活动时自动注销的功能。不必要的绑定。请告诉我我要去哪里了
import React from 'react';
import ReactDOM from 'react-dom';
import './App.css';
class Toogle extends React.Component {
constructor(props) {
super(props);
//step 1
this.handleClick = this.handleClick.bind(this);
this.startTimer=this.startTimer.bind(this)
}
handleClick() {
console.log('Button is clicked');
// clearTimeout(timeoutTimer);
startTimer() {
var timeoutTimer = setTimeout(function() {
window.location.href = '#/security/logout';
}.bind(this), 1000);
}
}
render() {
return (<div onMouseMove={this.handleClick}>Move the cursor over me</div>);
}
}
ReactDOM.render(
<Toogle />,
document.getElementById('root')
);
Run Code Online (Sandbox Code Playgroud) 我正在尝试根据条件设置变量值,我想知道在 Java 8 中是否有更好的方法来做到这一点,而不是使用多个 if else 或 switch 语句。
我需要根据字符串值设置请求编号
123 为 foo,123 为 bar,456 为 xyz,000 作为默认值,即任何其他字符串值。
if(someString.equalsIgnorecase("foo")){
x = someObj.setRequestNumber(123);
}
else if(someString.equalsIgnorecase("bar")){
x = someObj.setRequestNumber(123);
}
else if(someString.equalsIgnorecase("xyz")){
x = someObj.setRequestNumber(456);
}
else{
x = someObj.setRequestNumber(000);
}
Run Code Online (Sandbox Code Playgroud)