写在前面
最近在项目中,需要使用中文转拼音的功能,在网上找到一款比较全面的js插件-pinyin.js
使用方法
1、安装
npm i pinyin
或者
npm i js-pinyin
2、使用方法
const PINYIN = require('pinyin');
const chinese = "绿色";
const pinyinSTYLE_NORMAL = PINYIN(chinese, {
style: PINYIN.STYLE_NORMAL,
})
const pinyinSTYLE_TONE = P