cookieJS_20210621201505.js 526 B

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