axios中对cookie的封装
来源:互联网 发布:智多星项目造价软件 编辑:程序博客网 时间:2024/05/22 00:50
function isStandardBrowserEnv() { if(typeof navigator !== 'undefined' && navigator.product === 'ReactNative'){ return false; } return ( typeof window !== 'undefined' && typeof document !== 'undefined' );}function isNumber(val) { return typeof val === 'number';}function isString(val) { return typeof val === 'string';}var cookies = (isStandardBrowserEnv() ? (function standardBrowserEnv(){ return { write: function write(name, value, expires, path, domain, secure) { var cookie = []; cookie.push(name + '=' + encodeURIComponent(value)); if(isNumber(expires)) { cookie.push('expires=' + new Date(expires).toGMTString()); } if(isString(path)) { cookie.push('path=' + path); } if(isString(domain)) { cookie.push('domain=' + domain); } if(secure === true) { cookie.push('secure'); } document.cookie = cookie.join('; '); }, read: function read(name) { var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); return (match ? decodeURIComponent(match[3]) : null); }, remove: function remove(name) { this.write(name, '', Date.now() - 86400000); } }; })() : (function nonStandardBrowserEnv(){ return { write: function write() {}, read: function read() { return null; }, remove: function remove() {} }; })());
阅读全文
0 0
- axios中对cookie的封装
- vue项目中对axios的封装
- vue 中axios的封装
- 对Cookie操作的封装
- 封装简单的axios库
- 使用JavaScript 对Cookie 操作的封装
- axios封装
- axios 封装
- Javascript 中Cookie的封装问题
- vue中axios的使用方法
- vue实力封装axios
- vue axios 二次封装
- vue 封装 axios
- vue项目封装axios
- cookie操作的封装
- / 封装cookie的操作方法
- cookie的简单封装
- cookie的封装
- Linux 查看进程、关闭进程
- Handler基本使用(二)new Message 、 Handler.obtainMessage和Message.obtain
- Oracle_一点整理
- 文山湖畔
- 20个编写现代CSS代码的建议
- axios中对cookie的封装
- 9月29日 开始用博客记录我的学习之旅 (产品)
- 用ngrok做内网穿透
- css翻转元素
- runtime的基础学习
- MySQL 获得当前日期时间(以及时间的转换)
- 第三章、高级查询
- Runtime常用的几个应用场景(可以先看上一篇文章)
- 大学,大学,大学