cookieJS_20210621201500.js 541 B

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