黑白梦黑白梦

toggle navtoggle nav
  • 文章
  • 专栏
  • 文章
  • 专栏

pinyin 汉字转拼音

发布于 2020-07-13, 更新于 2023-04-08

转换中文字符为拼音。可以用于汉字注音、排序、检索。

https://github.com/hotoo/pinyin

npm install pinyin

可设置是否带声调、可只返回首字母、可考虑多音字。

支持web和node。

内置了排序规则:

const pinyin = require('pinyin');

const data = '我要排序'.split('');
const sortedData = data.sort(pinyin.compare);
本文收录于专栏

一些好用的 npm 前端开源库

收集一些好用的前端开源库,主要是 npm 包

©2015-2026 黑白梦 粤ICP备15018165号

联系: heibaimeng@foxmail.com