vue登录

login(){


  var url = "登录地址"

  var param = {

  username:this.username,

  pwd:this.password

  }

  param=qs.stringify(param)


  this.axios.post(url,param).then((res)=>{

  if(this.username!==""&&this.password!==""){

  console.log(res.data.data)

  console.log(res.data.data.user_id)

cookies.set('token',res.data.data.user_id)

this.$router.push("/homepage")

this.username=""

this.password=""

  }else if(this.username==""){

  alert("账号不能为空")

  }else if(this.password==""){

  alert("密码不能为空")

  }else{

  alert("密码和账号不能为空")

  }

  })


  }

你可能感兴趣的:(vue登录)