一、安装
npm install js-pinyin --save
二、使用
script标签中引入
<script>
let pinyin = require('js-pinyin');
export default {
data(){
return{
}
},
mounted(){
console.log(pinyin.getFullChars('博客'));//BoKe
console.log(pinyin.getCamelChars('博客'));//BK
console.log(pinyin.getCamelChars('12博客34'));//12BK34
console.log(pinyin.getCamelChars('a博客b'));//aBKb
}
};
</script>