npm install js-pinyin
main.js 引入
import pinyin from ‘js-pinyin‘
使用组件内
let pinyin = require(‘js-pinyin‘);
pinyin.setOptions({checkPolyphone: false, charCase: 0});
console.log(pinyin.getFullChars(‘管理员‘));
console.log(pinyin.getCamelChars(‘管理员‘));
console.log(pinyin.getCamelChars(‘1234‘));
console.log(pinyin.getCamelChars(‘english‘));
获取拼音首字母