arale-cookie 使用

https://www.npmjs.com/package/arale-cookie  arale-cookie 使用npm

define(function() {
    var Cookie = require('cookie');
 
    Cookie.set('foo', 3);
 
    Cookie.set('bar', 4, {
        domain: 'example.com',
        path: '/',
        expires: 30
    });
});

define(function() {
    var Cookie = require('cookie');
 
    Cookie.remove('foo');
 
    Cookie.remove('bar', {
        domain: 'example.com',
        path: '/'
    });
});

define(function() {
    var Cookie = require('cookie');
 
    // setup
    document.cookie = 'foo=1';
    document.cookie = 'bar=2';
 
    Cookie.get('foo');
    // returns '1'
 
    Cookie.get('bar', function(s) { return parseInt(s); } );
    // returns 2
});
相關文章
相關標籤/搜索