Vue后台管理系统实现登录功能
生活随笔
收集整理的這篇文章主要介紹了
Vue后台管理系统实现登录功能
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
登錄頁面
vuex
router.js
main.js設(shè)置全局
退出功能刪除token 清空localStorage
顯示用戶名
鍵盤事件
** 記住密碼操作( 讀存取cookie與調(diào)后端數(shù)據(jù)無關(guān) 提交按鈕中操作 )**
點(diǎn)擊事件
設(shè)置cookie
//設(shè)置cookiesetCookie(c_name, c_pwd, exdays) {var exdate = new Date(); //獲取時(shí)間exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * exdays); //保存的天數(shù)//字符串拼接cookiewindow.document.cookie ="userName" + "=" + c_name + ";path=/;expires=" + exdate.toGMTString();window.document.cookie ="userPwd" + "=" + c_pwd + ";path=/;expires=" + exdate.toGMTString();},讀取cookie
//讀取cookiegetCookie: function() {if (document.cookie.length > 0) {var arr = document.cookie.split("; "); //這里顯示的格式需要切割一下自己可輸出看下for (var i = 0; i < arr.length; i++) {var arr2 = arr[i].split("="); //再次切割//判斷查找相對應(yīng)的值if (arr2[0] == "userName") {this.formInline.account = arr2[1]; //保存到保存數(shù)據(jù)的地方 用戶名} else if (arr2[0] == "userPwd") {this.formInline.password = arr2[1]; //保存到保存數(shù)據(jù)的地方 密碼}}}},清除cookie
//清除cookieclearCookie: function() {this.setCookie("", "", -1); //修改2值都為空,天數(shù)為負(fù)1天就好了}mounted調(diào)用
mounted() {this.getCookie();調(diào)用}總結(jié)
以上是生活随笔為你收集整理的Vue后台管理系统实现登录功能的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vue+element-ui实现表格的增
- 下一篇: html5倒计时秒杀怎么做,vue 设