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:保留首字母大写