相关疑难解决方法(0)

如何优雅地检测JavaScript中的空闲时间?

是否可以在JavaScript中检测" 空闲 "时间?
我的主要用例可能是预取或预加载内容.

空闲时间:用户不活动或没有任何CPU使用的时间段

javascript

451
推荐指数
18
解决办法
31万
查看次数

当用户在ReactJS中处于非活动状态时,如何自动注销?

我需要知道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)

reactjs

7
推荐指数
2
解决办法
1万
查看次数

标签 统计

javascript ×1

reactjs ×1