SetInterval is overwritten at execution time

click: () => {
 _this = this
 _this.scheduleName = params.row.name
 axios({
 method: "post",
 url: "/get_schedule/",
 data: Qs.stringify({"schedule_start":params.row.name})
      }).then(function (response){
_this.percentClock[_this.scheduleName] = setInterval("_this.test1(_this.scheduleName)", 3000) 
        })
   }

this code corresponds to the start button on the front end

clipboard.png
starttest1test1
:
q1startstartsetInterval()

clipboard.png

test1console.log(taskId)q1 start

clipboard.png
4Q1()q2start

clipboard.png
q1
q1100%

clipboard.png
all codes

render: (h, params) => {
        return h("div", [
            h("i-button", {
                props: {
                    type: "error",
                    size: "small",
                },
                style: {
                    marginRight: "5px"
                },
                on: {
                    click: () => {
                         _this = this
                         _this.scheduleName = params.row.name
                         axios({
                             method: "post",
                             url: "/delete_graph/",
                             data: Qs.stringify({"start_name":params.row.name})
                         })
                         axios({
                         method: "post",
                         url: "/get_schedule/",
                         data: Qs.stringify({"schedule_start":params.row.name})
                         }).then(function (response){
                            _this.percentClock[_this.scheduleName] = setInterval("_this.test1(_this.scheduleName)", 3000) 
                            })
                    }
                }
            }, "Start")
---------------------------------------
test1(taskId) {
    console.log(taskId)
    _this = this
    axios({
     method: "post",
     url: "/get_schedule/",
     data: Qs.stringify({"schedule_start":this.scheduleName})
    }).then(function (response){
         //console.log(response.data)
         _this.$nextTick(() => {
            if (_this.progress["percentage" + taskId] === undefined) {
                 Vue.set(vm.progress, "percentage" + taskId, "0")
                 Vue.set(vm.progress, "loss" + taskId, "0")
                 Vue.set(vm.progress, "status" + taskId, "")
            }
            if (response.data[taskId].epoch_index === undefined) {
                _this.progress["percentage" + taskId] = 0
                _this.progress["loss" + taskId] = 0
            } 
            if (_this.watchPause === "") {
                console.log("sucee")
                _this.progress["percentage" + taskId] = response.data[taskId].epoch_index
                localStorage.setItem("percentage" + taskId,response.data[taskId].epoch_index)
            }
            else{
                _this.progress["percentage" + taskId] = response.data[taskId].epoch_index
                _this.progress["loss" + taskId] = response.data[taskId].epoch_loss
                //console.log(_this.progress)
                }
            })
         if (response.data[taskId].epoch_index === 10) {
            
            console.log("success")
            localStorage.setItem("percentage" + taskId,response.data[taskId].epoch_index)
            localStorage.setItem("loss" + taskId,response.data[taskId].epoch_loss)
            clearInterval(_this.percentClock[taskId])
         }
    })
},
            

does the landlord call the same function?
seems to be a variable scope problem. Correction: the problem is that the same object is referenced. Change the
to a closure?

-supplement

that means that your previous function variable has been modified, and you can change it to a closure. Let him be a scope alone

click: () => {
     _this = this
     // _this.scheduleName = params.row.name
     axios({
     method: 'post',
     url: '/get_schedule/',
     data: Qs.stringify({'schedule_start':params.row.name})
    }).then(function (response){
        (function(scheduleName){
          _this.percentClock[scheduleName] = setInterval('_this.test1(scheduleName)', 3000) 
        })(params.row.name)
    })
   }

-modify
if you write setInterval ('_ this.test1 (scheduleName)', 3000)
parameter scheduleName, he will read this.scheduleName;

click: () => {
     _this = this
     var scheduleName = params.row.name;
     
     let scheduleName = params.row.name;
     axios({
     method: 'post',
     url: '/get_schedule/',
     data: Qs.stringify({'schedule_start':params.row.name})
    }).then(function (response){
          _this.percentClock[scheduleName] = setInterval(()=>{
              _this.test1(scheduleName)
          }, 3000) 
    })
   }

what is equivalent to overwriting?
'_ this.test1 (_ this.scheduleName)' what is done in quotation marks?

should not be overwritten and executed. Please take a closer look. Even if the _ this.percentClock [_ this.scheduleName] name is the same, there will be no overwriting, and once it starts, it won't end. The same will not be overwritten, only manual clearInterval will end

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3023a-4d38c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3023a-4d38c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?