vue 中文转拼音

 

安装:

npm install js-pinyin --save

在 script 引入:

let pinyin = require('js-pinyin');
methods:
getTitle(title) {
    const py = pinyin.getFullChars(title)
    return py.replace(/[^0-9a-zA-Z]/g, '');
},
template:
<div class="titlePingyin">{{ getTitle(items.SYS_TOPIC) }}</div>

 


 

getFullChars:拼音全称
getCamelChars:保留首字母大写

 

posted @ 2024-07-02 15:25  小蘑菇123  阅读(9)  评论(0)    收藏  举报