首页 > 其他 > 详细

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

时间:2018-05-28 10:32:02      阅读:333      评论:0      收藏:0      [点我收藏+]
 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);    //清除定时器
    }

 

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

原文:https://www.cnblogs.com/cocoxia/p/9098689.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!