vue项目中使用 pinyin转换插件

npm install js-pinyin

具体使用的文件中 import

import pinyin from '../../../node_modules/js-pinyin/index'


使用

console.log(pinyin.getFullChars('管理员')) //GuanLiYuan;
console.log(pinyin.getCamelChars('管理员')) //GLY;
console.log(pinyin.getCamelChars('1234')) //1234;
console.log(pinyin.getCamelChars('杨'))  //Y;

ps: 可能有 import export 冲突 这时候你需要检查一下node_modules中 js-pinyin插件的导出方式是否是es6

猜你喜欢

转载自blog.csdn.net/weixin_38644883/article/details/88884460
今日推荐