中文转拼音

作者: 随行者pgl | 来源:发表于2022-04-08 15:29 被阅读0次

1. 安装

js-pinyin npm地址

npm install js-pinyin --save

2. 引入及使用

<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>

相关文章

网友评论

    本文标题:中文转拼音

    本文链接:https://www.haomeiwen.com/subject/kneysrtx.html