cookieJS_20210621201552.js 656 B

1234567891011121314151617181920212223242526
  1. /*
  2. * @Description: cookie封装
  3. * @Author: Napier
  4. * @LastEditors: Napier
  5. * @LastEditorTime:
  6. */
  7. export default {
  8. /**
  9. * @description:设置cookie
  10. * @param {*} value:值
  11. * @param {*} saveDays :保存的
  12. * @param {*} cookieName
  13. */
  14. setCookie: function (value, saveDays, cookieName) {
  15. let date = new Date()
  16. date.setTime(date.getTime() + saveDays * 24 * 60 * 60 * 1000)
  17. document.cookie = cookieName + '=' + escape(value) + ';expires=' + date.toGMTString()
  18. },
  19. // 获取cookie
  20. getCookie: function (name) {
  21. var v = window.document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)')
  22. return v ? v[2] : null
  23. }
  24. }