# em-cookie

> cookie工具

Latest version **1.1.1** (published 2018-11-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install em-cookie
pnpm add em-cookie
yarn add em-cookie
bun add em-cookie
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2018-11-16 |
| First published | 2017-09-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | 李梦龙 |
| Maintainers | em-fe |
| Keywords | cookie, vue, em-cookie |

## Links

- npm: https://www.npmjs.com/package/em-cookie
- Repository: https://github.com/em-fe/em-cookie
- Homepage: https://github.com/em-fe/em-cookie#readme
- Issues: https://github.com/em-fe/em-cookie/issues
- npm.io page: https://npm.io/package/em-cookie

## Recent versions

- 1.1.1 (latest) — 2018-11-16
- 1.1.0 — 2018-11-05
- 1.0.6 — 2017-10-31
- 1.0.5 — 2017-10-30
- 1.0.4 — 2017-10-26
- 1.0.3 — 2017-10-25
- 1.0.2 — 2017-10-11
- 1.0.1 — 2017-09-29
- 1.0.0 — 2017-09-29

## README

# em-cookie
cookie的相关操作

[![em-cookie](https://img.shields.io/npm/v/em-cookie.svg?style=flat-square)](https://www.npmjs.org/package/em-cookie)
[![NPM downloads](http://img.shields.io/npm/dm/em-cookie.svg?style=flat-square)](https://npmjs.org/package/em-cookie)
[![Package Quality](http://npm.packagequality.com/shield/em-cookie.svg)](http://packagequality.com/#?package=em-cookie)
[![NPM downloads](https://img.shields.io/npm/dt/em-cookie.svg?style=flat-square)](https://npmjs.org/package/em-cookie)

## 为什么用？

 * 减少项目之间重复的代码
 * 公共方法抽离
 * 使用方便
 * 模块化，用哪个，引哪个
 * 易于维护

## 怎么用？
在vue中可以使用，像挂载其他ui库一样。
 ```js
 import cookie from 'em-cookie';
 Vue.use(VueCookie);
 // 普通用法
 console.log(window.$cookie.get('aaa'));
 // vue 用法
 console.log(this.$cookie.get('aaa'));
 ```

### set 方法
 > 1.0.7 版本之前必须设置时间

##### 参数

 `window.$cookie.set(key, value, expireValue, path, domain, secure);`

|属性|说明|类型|是否必须|默认|
|---|---|----|-------|---|
|key|存储的键值|String|是|无|
|value|存储内容|String|是|无|
|expireValue|过期时间。可用值: 年(y)，月(m)，日(d)，时(h)，分(min)，秒(s)|[String,Number]|否`1.0.7` 之前必传`|1d(一天)|
|path|存储的作用路径|String|否|`/`|
|domain|存储的作用的 domain|String|否|`document.domain`|
|secure|Cookie 只能通过安全协议传输为 https 。在 Chrome 52之前，此标记可能会显示来自 http 域的 Cookie 。|Boolean|否|无|

### get 方法

 `window.$cookie.get(key);`

|属性|说明|类型|是否必须|默认|
|---|---|----|-------|---|
|key|获取的键值|String|是|无|

### remove 方法

 `window.$cookie.remove(key, path, domain);`

|属性|说明|类型|是否必须|默认|
|---|---|----|-------|---|
|key|获取的键值|String|是|无|
|path|存储的作用路径|String|否|`1.0.7` 开始默认`/`|
|domain|存储的作用的 domain|String|否|`1.0.7` 开始默认`document.domain`|

## 安装

  * npm

  `npm install em-cookie`

  * yarn

  `yarn add em-cookie`

---
_Source: https://npm.io/package/em-cookie · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
