首页 > Web开发 > 详细

js --》 如何防止在请求接口时,禁止重复使用该接口?(重复提交问题)

时间:2020-01-02 20:32:25      阅读:246      评论:0      收藏:0      [点我收藏+]
<template>
  <div>

  </div>
</template>

<script>
import api from "@/components/api.vue";
import qs from "qs";
export default {
  data() {
    return {
      websockFlag: true,//开关变量
    };
  },
  methods: {
   //保存 saveItem() {
if (!websockFlag) { this.$message("正在请求中,请勿重复操作!"); this.websockFlag = true; return; } let parm = { token: JSON.parse(localStorage.userMsg).token, point_key: this.point_key, control_value: this.control_value }; this.websockFlag = false; // 解决异步,不要写在api请求中 api.selectUserInfo(qs.stringify(param)).then(res => { if (res) { this.websockFlag = true; //清零 该次请求未完成,不允许进行下次请求 } if (res.code != 200) { this.$message({ message: "请求失败!", type: "success", showClose: true }); } }); } } }; </script> <style lang="scss"> </style>

js --》 如何防止在请求接口时,禁止重复使用该接口?(重复提交问题)

原文:https://www.cnblogs.com/wangqi2019/p/12134618.html

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