国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

輕量級JS Cookie插件js-cookie的使用方法

來源:懂視網 責編:小采 時間:2020-11-27 22:17:19
文檔

輕量級JS Cookie插件js-cookie的使用方法

輕量級JS Cookie插件js-cookie的使用方法:Cookie是網站設計者放置在客戶端的小文本文件,一般后臺語言使用的比較多,可以實現用戶個性化的一些需求。js-cookie插件是一個JS操作cookie的插件,源文件只有3.34 KB,非常輕量級。js-cookie也支持npm和Bower安裝和管理。下面看看js-cookie的具體
推薦度:
導讀輕量級JS Cookie插件js-cookie的使用方法:Cookie是網站設計者放置在客戶端的小文本文件,一般后臺語言使用的比較多,可以實現用戶個性化的一些需求。js-cookie插件是一個JS操作cookie的插件,源文件只有3.34 KB,非常輕量級。js-cookie也支持npm和Bower安裝和管理。下面看看js-cookie的具體

Read all visible cookies:

Cookies.get(); // => { name: 'value' }

Delete cookie:

Cookies.remove('name');

Delete a cookie valid to the path of the current page:

Cookies.set('name', 'value', { path: '' });
Cookies.remove('name'); // fail!
Cookies.remove('name', { path: '' }); // removed!

IMPORTANT! When deleting a cookie, you must pass the exact same path and domain attributes that were used to set the cookie, unless you're relying on the default attributes.

Note: Removing a nonexistent cookie does not raise any exception nor return any value.

Namespace conflicts

If there is any danger of a conflict with the namespace Cookies, the noConflict method will allow you to define a new namespace and preserve the original one. This is especially useful when running the script on third party sites e.g. as part of a widget or SDK.

// Assign the js-cookie api to a different variable and restore the original "window.Cookies"

var Cookies2 = Cookies.noConflict();
Cookies2.set('name', 'value');

Note: The .noConflict method is not necessary when using AMD or CommonJS, thus it is not exposed in those environments.

JSON

js-cookie provides unobtrusive JSON storage for cookies.

When creating a cookie you can pass an Array or Object Literal instead of a string in the value. If you do so, js-cookie will store the string representation of the object according to JSON.stringify:

Cookies.set('name', { foo: 'bar' });

When reading a cookie with the default Cookies.get api, you receive the string representation stored in the cookie:

Cookies.get('name'); // => '{"foo":"bar"}'
Cookies.get(); // => { name: '{"foo":"bar"}' }

When reading a cookie with the Cookies.getJSON api, you receive the parsed representation of the string stored in the cookie according to JSON.parse:

Cookies.getJSON('name'); // => { foo: 'bar' }
Cookies.getJSON(); // => { name: { foo: 'bar' } }

Note: To support IE6-7 (and IE 8 compatibility mode) you need to include the JSON-js polyfill: https://github.com/douglascrockford/JSON-js

更多的可以參考官方說明:

https://github.com/js-cookie/js-cookie

https://www.npmjs.com/package/js-cookie

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

輕量級JS Cookie插件js-cookie的使用方法

輕量級JS Cookie插件js-cookie的使用方法:Cookie是網站設計者放置在客戶端的小文本文件,一般后臺語言使用的比較多,可以實現用戶個性化的一些需求。js-cookie插件是一個JS操作cookie的插件,源文件只有3.34 KB,非常輕量級。js-cookie也支持npm和Bower安裝和管理。下面看看js-cookie的具體
推薦度:
標簽: cookie js cookies
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 国产偷窥在线观看 | 欧美在线视频一区二区三区 | 2021国产精品成人免费视频 | 在线视频观看国产 | 中文国产成人精品久久96 | 国产成人91一区二区三区 | 中文字幕第7页 | 国产精品1区 | 国产精品成 | 色在线免费视频 | 久久精品一区二区 | 在线观看国产精品入口 | 国产不卡在线 | 韩国精品欧美一区二区三区 | 日韩综合在线 | 欧美日韩一区二区三区在线观看 | 一级一黄在线观看视频免费 | 中文国产成人精品久久一 | 亚洲欧美日韩在线观看 | 日本黄 色 成 年 人免费观看 | 五月天婷婷丁香 | 国产视频资源在线观看 | 图片区 日韩 欧美 亚洲 | 国产成人精品免费视 | 久久精品国产三级不卡 | 一区精品麻豆经典 | 久久精品一区 | 国内精品一区二区三区最新 | 成人一级免费视频 | 国产高清在线看 | 欧美日一区二区三区 | 日韩亚洲欧美一区二区三区 | 日日做夜夜爱 | 国产淫语对白在线 | 国产欧美一区二区精品性色99 | 五月天丁香网 | 欧美日韩大尺码免费专区 | 欧美.com| 成人久久精品 | 国产精品免费观看视频 | 欧美成人一区二区三区在线视频 |