Vue/vant——验证登录页面跳转到个人中心
生活随笔
收集整理的這篇文章主要介紹了
Vue/vant——验证登录页面跳转到个人中心
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
如果沒有勾選協議,那么就提示先勾選協議,當協議被勾選成功后進入加載動畫以及隱藏提交文字,然后判斷正確的賬號和密碼?來獲取請求,如果賬號密碼錯誤則不可獲取請求,也會判定賬號密碼錯誤,只有輸入成功后才能成功獲取數據進入對應的頁面里
?
methods: {// 回退上個頁面back(){this.$router.go(-1);},iconClick() {this.$router.push("/Myfile");},// 此處使用函數校驗validator(val) {return /^.{5,20}$/.test(val);},sub() {if (!this.check) {Toast("請先同意協議");} else {this.pshow = falsethis.show = truesetTimeout(() => {this.$axios.post("/login", {username: this.username,password: this.password,}).then((result) => {console.log(result);if (this.username === result.data.data.username ||this.password === result.data.data.password) {Toast("登陸成功!");return this.$router.push("/Myfile");}else{Toast('賬號或密碼不正確,請重新輸入')this.pshow = truereturn this.show= false}}).catch((err) => {console.log("數據請求錯誤,請聯系工作人員");return Toast('賬號或密碼不正確,請重新輸入')});}, 1000);setTimeout(() => {this.pshow = truereturn this.show= false}, 1500);}},效果如下所示:
?
?
總結
以上是生活随笔為你收集整理的Vue/vant——验证登录页面跳转到个人中心的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Dijkstra(单源最短路径)
- 下一篇: html5倒计时秒杀怎么做,vue 设