js - "How to Prevent upon request interface, this interface should not be repeated? (Repeat submit questions)

<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("Being requested, do not repeat! " ); The this .websockFlag = to true ; return ; } the let parm = { token: the JSON.parse (localStorage.userMsg) .token, point_key: the this .point_key, control_value: the this .control_value } ; the this .websockFlag = to false ; // solve asynchronous, do not write request api the then (RES api.selectUserInfo (qs.stringify (param)). => { IF (RES) { the this .websockFlag= To true ; // clears the request times is not completed, the next request is not allowed } IF (res.code =! 200 is ) { the this $ Message ({. Message: " ! Request failed " , type: " Success " , showClose: to true }); } }); } } }; </ Script > < style lang = "SCSS" > </ style >

Guess you like

Origin www.cnblogs.com/wangqi2019/p/12134618.html