login.js 889 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. let app = new Vue({
  2. el: '#app',
  3. data () {
  4. return {
  5. accounts:'',
  6. password:'',
  7. userList:[
  8. {accounts:'123',password:'456'},
  9. {accounts:'admin',password:'123456'}
  10. ]
  11. }
  12. },
  13. created () {
  14. },
  15. beforeDestroy () {
  16. },
  17. mounted () {
  18. },
  19. methods: {
  20. goIndex(){
  21. console.log(this.accounts,this.password)
  22. for(let a = 0;a<this.userList.length;a++){
  23. if(this.userList[a].accounts == this.accounts){
  24. if(this.userList[a].password == this.password){
  25. this.$message({
  26. message: '登录成功',
  27. type: 'success'
  28. });
  29. sessionStorage.setItem('accounts',this.accounts);
  30. sessionStorage.setItem('password',this.accounts);
  31. return
  32. }
  33. }
  34. }
  35. this.$message.error('用户名不存在或密码错误');
  36. }
  37. },
  38. })