GET请求携带参数
xuexi 2024-06-07 11:39:22 发表在:VUE 查看数:710
login(){
         axios.get('http://localhost:9090/user/login', {
          // 传递的参数
          params: {
             // 账号
             account:this.formLogin.account,
             // 密码
             password:this.formLogin.password,
             // 测试参数
             testParam:'hello world'
          }
          // 回调函数,一定要使用箭头函数,不然this的指向不是vue示例
          }).then(res =>{
           // 如果状态为400,说明登录失败
             if(res.data.status===400){
                // 登录失败提示
                this.$message({showClose: true, message: '登录失败,请检查账号和密码!',type: 'error', duration:2000,center:true});
             }else{
                // 登录成功提示
                this.$message({showClose: true, message: '登录成功!',type: 'success', duration:2000,center:true});
                // 跳转到首页路由
                this.$router.push("/main/home");
             }
          }).catch(error =>{
             console.log(error)
          })
      },
最近访问时间:2025-02-06 22:47:26
知识库:318条鸣谢:TAY  备案号:蜀ICP备2024090044号