The LocalStorage class is used for data storage without time limit.

LocalStorage 类用于没有时间限制的数据存储。

构造函数

属性

items: any

Data list.

数据列表。

support: boolean = false

Indicates whether LocalStorage is supported.

表示是否支持 LocalStorage

方法

  • 参数

    • key: string

      The key name.

    返回 string

    The string value associated with the key.

    Retrieves the value for the specified key.

    获取指定键名的值。

  • 参数

    • key: string

      The key name.

    返回 any

    The Object value associated with the key.

    Retrieves the Object value for the specified key.

    获取指定键名对应的 Object 类型值。

  • 参数

    • key: string

      The key name.

    返回 void

    Removes the item associated with the specified key.

    删除指定键名的信息。

  • 参数

    • key: string

      The key name.

    • value: string

      The value to store.

    返回 void

    Stores a key-value pair as strings.

    存储指定键名和键值,字符串类型。

  • 参数

    • key: string

      The key name.

    • value: any

      The value to store. It's an Object type and will be converted to a JSON string for storage.

    返回 void

    Stores a key-value pair where the value is an Object.

    存储指定键名及其对应的 Object 类型值。