npm install js-pinyin --save
<script>
const pinyin = require('js-pinyin');
export default {
methods: {
test(){
console.log( pinyin.getFullChars('明天也要努力') ); // MingTianYeYaoNuLi
console.log( pinyin.getCamelChars('明天也要努力') ); // MTYYNL
console.log( pinyin.getCamelChars('12明天也要努力34') ); // 12MTYYNL34
console.log( pinyin.getCamelChars('a明天也要努力b') ); // aMTYYNLb
}
},
mounted(){
this.test();
}
}
</script>