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

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

构造函数

访问器

  • get count(): number
  • 返回 number

    The number of items.

    Retrieves the number of items stored in local storage.

    获取本地存储中存储的项目数量。

方法

  • 参数

    • 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 类型值。