Skip to content
关注公众号,获取新课通知

获取通讯录列表


具体看课程演示

https://www.npmjs.com/package/sort-word

安装

shell
npm install sort-word -S

使用

第三参数为true时 添加热门项,默认添加传入数组前10个 不需要热门项,则不需要传第三个参数

js
import SortWord from "sort-word";

let arr = [{ name: "张三" }, { name: "李四" }];
let newArr = new SortWord(arr, "name");

/*
  newArr {
    newList:[
      {title: 'L', list: [{name: '李'}]},
      {title: 'Z', list: [{name: '张'}]}
    ],
    indexList: ['L', 'Z'],
    total: 2
  }
  */