External module @tomato-js/cookie
Functions
get
- get(name: string, cookie?: string): null | string
-
Parameters
-
name: string
-
Default value cookie: string = document.cookie
Returns null | string
对应key的value值
has
- has(name: string, cookie?: string): boolean
-
Parameters
-
name: string
-
Default value cookie: string = document.cookie
Returns boolean
是否存在
remove
- remove(name: string, options?: RemoveOptions): boolean
-
Parameters
-
name: string
-
Default value options: RemoveOptions = {path: "/",domain: ""}
Returns boolean
是否删除成功
set
- set(name: string, value: string, options?: SetOptions): boolean
-
Parameters
-
name: string
-
value: string
-
Default value options: SetOptions = {}
Returns boolean
是否设置成功
取cookie值
脚本举例
import { get } from '@tomato-js/cookie' get('name');