cookie的设置与取值
设置cookie function cookie(key, value, options) { let days let time let result // A key and value were given. Set cookie. if (arguments.length > 1 && String(value) !== '[object Object]') { // Enforce object options = Object.assign({}, options) if (value === null || value === undefined) { options.expires = -1 } if (typeof options.expires === 'number') { days = options.expires * 24 * 60 * 60 * 1000 time = options.expires = new Date() time.setTime(time.getTime() + days) } value = String(value) return (document.cookie = `${encodeURIComponent(key)}=${ options.raw ? value : encodeURIComponent(value) }