zoukankan      html  css  js  c++  java
  • 一些工具方法

    getCookie (name) { // 获取cookie
        const cookieContent = '; ' + document.cookie
        const cookies = cookieContent.split(`; ${name}=`)
        return cookies.length - 1 ? cookies.pop().split(';').shift() : ''
     },
    setCookie (name, val, days) { // 设置cookie
        let expires = ''
        if (days) {
          const date = new Date()
          date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))
          expires = `; expires=${date.toUTCString()}`
        }
        document.cookie = `${name}=${val}${expires}; path=/`
    },
    delCookie (name) {
        var exp = new Date()
        exp.setTime(exp.getTime() - 1)
        var cval = this.getCookie(name)
        if (cval != null) {
          document.cookie = name + '=' + cval + ';expires=' + exp.toGMTString() + ';path=/;domain = .zhaopin.com'
        }
    },
    //退出系统时调用
    deleteSession () {
        const env = process.env.NODE_ENV
        const empId = Common.getCookie('xxx')
        sessionStorage.removeItem(`${env}${empId}leftMenu`)
    },
    
  • 相关阅读:
    Python day 34 并发编程、PID/PPID、实现多进程得两种方式
    Python Day33:粘包问题及粘包解决方案
    数据分析
    数据分析
    爬虫 之 mongodb数据库
    爬虫
    爬虫
    爬虫
    flask框架
    flask框架
  • 原文地址:https://www.cnblogs.com/yangAL/p/10525159.html
Copyright © 2011-2022 走看看