zoukankan      html  css  js  c++  java
  • react中使用屏保

    1,默认路由路径为屏保组件

     1 <HashRouter history={hashHistory}>
     2                     <Switch>
     3                      <Route exact path="/" component={ScreenSaver} />
     4                         <Route exact path="/brandIntroduce" component={BrandIntroduce} />
     5                         <Route exact path="/category" component={Category} />
     6                         <Route exact path="/productList/:id" component={ProductList} />
     7                         <Route exact path="/productDetail/:id" component={ProductDetail} />
     8                         <Route exact path="/officialWebsite" component={OfficialWebsite} />
     9                     </Switch>
    10                 </HashRouter>

    2,render部分,父级加入点击事件

    1 <div className="main-container" onClick={this.handleClick}>

    3,点击事件,定时10分钟,无点击屏幕,调到屏保组件中,起到屏保作用

    1     handleClick() {
    2         clearTimeout(timeout1);
    3         timeout1 = setTimeout(() => {
    4             LocalServices.saveSelectedSlide('');
    5             hashHistory.push('/');
    6             // location.reload();
    7         },100000);
    8     },
  • 相关阅读:
    Css_加载样式
    Mvc4_@RenderBody()和@RenderSection()
    C#_观察者模式
    Mvc4_MvcPager 概述
    Mvc4_Area的应用
    Nginx 服务器性能参数设置
    Nginx变量的实现机制
    天下无雾
    Nginx Http框架的理解
    【转】websocket协议规范
  • 原文地址:https://www.cnblogs.com/yinhao-jack/p/10619933.html
Copyright © 2011-2022 走看看