Vue.js: a this problem

goLogin() {
        console.log(url.loginIn)
         this.loading = true
        if (this.userInfo.phone == "" || this.userInfo.password == "") {
            this.$message.error("");
            this.loading = false
        } else {
            this.$axios.post(url.loginIn,{phone: this.userInfo.phone,password: this.userInfo.password})
                .then(response => {
                    console.log(response);
                    if (response.status == 200) {
                        this.loading = false
                        if (response.data.resultCode == 1) {
                            this.$message({message:"", type:"success"});
                        } else {
                            this.$message.error("");
                            return
                            this.loading = false
                        }
                    } 
                })
                .catch(function(error) {
                    console.log(error);
                    this.loading = false
                    alert("")
                       
                });
        }
    },
    
    
    this.loading = true.catch()this.loading = false:TypeError: Cannot set property "loading" of undefined
Aug.13,2021

.catch((error) => {
                    console.log(error);
                    this.loading = false
                    alert('')
                       
                });

arrow function, because of the arrow function you used above, you can
clipboard.png


try to write the functions in catch as arrow functions. The orientation of this may be lost

.
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-1b3fca1-2c4ec.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-1b3fca1-2c4ec.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?