Options
All
  • Public
  • Public/Protected
  • All
Menu

External module @tomato-js/cookie

Index

Functions

Functions

get

  • get(name: string, cookie?: string): null | string
  • 取cookie值

    脚本举例

      import { get } from '@tomato-js/cookie'
      get('name');

    Parameters

    • name: string

      需要取的key

    • Default value cookie: string = document.cookie

      默认为document.cookie

    Returns null | string

    对应key的value值

has

  • has(name: string, cookie?: string): boolean
  • 判断cookie中是否有该值

    脚本举例

      import { has } from '@tomato-js/cookie'
      has('name');

    Parameters

    • name: string

      需要判断的key

    • Default value cookie: string = document.cookie

      默认为document.cookie

    Returns boolean

    是否存在

remove

  • remove(name: string, options?: RemoveOptions): boolean
  • 删除cookie中指定key

    脚本举例

      import { remove } from '@tomato-js/cookie'
      remove('name');

    Parameters

    • name: string

      需要删除的key

    • Default value options: RemoveOptions = {path: "/",domain: ""}

      其他参数

    Returns boolean

    是否删除成功

set

  • set(name: string, value: string, options?: SetOptions): boolean
  • 设置cookie中指定key和value

    脚本举例

      import { set } from '@tomato-js/cookie'
      set('name','brizer');

    Parameters

    • name: string

      需要设置的key

    • value: string

      需要设置的值

    • Default value options: SetOptions = {}

      其他参数

    Returns boolean

    是否设置成功

Generated using TypeDoc