1234567891011121314151617181920212223242526 |
- /*
- * @Description: cookie封装
- * @Author: Napier
- * @LastEditors: Napier
- * @LastEditorTime:
- */
- export default {
- /**
- * @description:设置cookie
- * @param {*} value:
- * @param {*} saveDays
- * @param {*} cookieName
- */
- setCookie: function (value, saveDays, cookieName) {
- let date = new Date()
- date.setTime(date.getTime() + saveDays * 24 * 60 * 60 * 1000)
- document.cookie = cookieName + '=' + escape(value) + ';expires=' + date.toGMTString()
- },
- // 获取cookie
- getCookie: function (name) {
- var v = window.document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)')
- return v ? v[2] : null
- }
- }
|