zoukankan      html  css  js  c++  java
  • 清除每隔5000毫秒请求一次接口的定时器(需求:每当我手动核销电子码,页面上的显示数据要实时更新到)

     import * as electron from "@/api/serverData/getServerData";
    methods:{
    
            electron(){   //请求接口数据
    
                var that = this;
                let _data = {
                    couponStatus : that.$route.params.status,
                    mealType :  that.$route.params.type
                }
                electron.setCouponStatusList(_data).then(res => {
                    //console.log(res)
                    that.voucherList = res.data.coupon;
    
            }
        },
        mounted() {
            this.electron();
            timer = setInterval(this.electron, 5000);   //每隔5000毫秒请求一次接口
        },
        destroyed () {
            clearInterval(timer);    //清除定时器
        }
  • 相关阅读:
    SSH异常
    jquery效果摘要
    js随笔
    html随笔
    demo小样
    SVG图标
    jQuery笔记
    html / css学习笔记-3
    angular 学习笔记
    ng-route使用笔记
  • 原文地址:https://www.cnblogs.com/cocoxia/p/9098689.html
Copyright © 2011-2022 走看看