0.0.0-alpha.0 • Published 4 years ago

@hapig/chat-vue-storage v0.0.0-alpha.0

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

chat-vue-storage

一、简介

提供数组数据的分页读写,及自定义配置

二、如何使用

安装 install

    yarn add chat-vue-storage / npm i chat-vue-storage

导入 import

    import ListStorage  from 'chat-vue-storage'

使用

  1. 创建实例并传入配置:
    const messageListStorage = new ListStorage({
        saveKey: 'chat-vue-history', // 存储的key
        pageSize: 10, // 分页大小
        limitNumber: 100, //最多存储数组的长度
    })
  1. 读写数据:
    // 存储数组数据
    // arrData 必选 Array, 必须为一个不为空的数组
    messageListStorage.addData(arrData)
    // 按分页读取数据
    // pageIndex 可选 Number,不传默认为 1
    // pageSize 可选 Number,不传默认使用实例化时传入配置中的pageSize
    messageListStorage.getData(pageIndex,pageSize)