1.npm安装
npm install js-pinyin
2.使用示例( charCase: 0 为大写;charCase: 1 为小写)
若不设置则默认为 charCase: 0
let pinyin = require("js-pinyin");
pinyin.setOptions({ checkPolyphone: false, charCase: 1 });
console.log(pinyin.getCamelChars('小明')); //xm
console.log(pinyin.getFullChars('博客'));//BoKe