每次调用方法时,如何使计时器重新启动?

问题描述

因此,我为正在制作的游戏设置了倒数计时器,该计时器需要一个计时器来计算每轮比赛后的用户总积分。因此,我需要在每个回合后重置30秒计时器。因此,我想我可以制作一种方法来重置计时器,因此每次需要更改轮次时都可以通过按钮调用它。但是,我觉得计时器类没有内置的重置功能,因此我尝试取消计时器,然后再次启动所有计时器,但无济于事。对如何使计时器重启有帮助吗?

 <div class="nav nav-tabs" id="nav-tab" role="tablist">
    
    <?PHP foreach ($categories as $category) {  ?>
    
      <a class="nav-item nav-link active" id="<?PHP echo $category->slug ?>" data-toggle="tab" href="#<?PHP echo $category->slug ?>" role="tab" aria-controls="<?PHP echo $category->slug ?>" aria-selected="true">
        <div class="img-obcenu"><img src="<?PHP echo z_taxonomy_image_url($category->term_id); ?>"></div>
        <h5><?PHP echo $category->cat_name; ?> </h5>
      </a>  
      
         <?PHP } ?>
         
    </div>
  </nav>       
  <div class="tab-content" id="nav-tabContent">
  
                <?PHP         
                $args  = array(
                'posts_per_page'  => -1,//'category'        => 'hot-drinks','orderby'         => 'post_date','order'           => 'ASC','post_type'       => 'food_menu','post_status'     => 'publish'
                //'category_name'   => $category->slug
                ); 
                $result = new WP_Query( $args);
            
                if ( $result-> have_posts() ) : ?>
  
    <div class="tab-pane fade show  active" id="<?PHP echo $category->slug ?>" role="tabpanel" aria-labelledby="<?PHP echo $category->slug ?>-tab">
      <div class="tabcontent">  
          <h2><?PHP echo $category->cat_name; ?> </h2>
        
        <div class="menutable">
          <div class="table-responsive">
            <table class="table">
              <thead>
                <tr>
                  <th class="bigBox"></th>
                  <th class="samllBox">S</th>
                  <th class="samllBox">M</th>
                  <th class="samllBox">L</th>
                </tr>
              </thead>
              <tbody>
                <?PHP while ( $result->have_posts() ) : $result->the_post(); ?>
         <tr>
                  <td class="bigBox">
                    <h3 class="p-title" data-toggle="modal" data-target="#menumodel"><?PHP the_title(); ?> <span class="border-list"></span></h3>
                    <p class="desc-p"><?PHP echo get_field('shot_descri',$post->ID);?></p>
                  </td>
                  <td class="samllBox">
                    <p class="pricing"><?PHP echo get_field('small_item_price_',$post->ID);?></p>
                  </td>
                  <td class="samllBox borderleft-right">
                    <p class="pricing"><?PHP echo get_field('medium_item_price_',$post->ID);?></p>
                  </td>
                  <td class="samllBox">
                    <p class="pricing"><?PHP echo get_field('large_item_price_',$post->ID);?></p>
                  </td>
                </tr>    
                
                <?PHP endwhile; ?>
                <?PHP endif; wp_reset_postdata(); ?>

              </tbody>
            </table>
          </div>
        </div>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)