cookieJS_20210311212743.js 452 B

123456789101112131415
  1. // cookie封装
  2. export default {
  3. // 设置cookie
  4. setCookie: function (value, saveDays, cookieName) {
  5. let date = new Date()
  6. date.setTime(date.getTime() + saveDays * 24 * 60 * 60 * 1000)
  7. document.cookie = cookieName + '=' + escape(value) + ';expires=' + date.toGMTString()
  8. },
  9. // 获取cookie
  10. getCookie: function (name) {
  11. var v = window.document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)')
  12. return v ? v[2] : null
  13. }
  14. }