Package Exports
- vpinyin
- vpinyin/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vpinyin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
描述
此方法可以将中文转换为拼音(转换后的首字母是大写)。也可以提取中文的首字母并大写。
下载
npm i vpinyin
引入
<script>
import vPinyin from '@/components/py/index.js'
</script>
使用
<script>
methods: {
//方法一 中文转拼音 valueName值为 中国人
chinesetoPinyin() {
//调用中文转拼音的方法
const resultPy = vPinyin.chineseToPinYin(this.valueName)
console.log(resultPy)//ZhongGuoRen
}
}
//方法二 提取首字母,并进行拼接
firstBig() {
const resultPy = vPinyin.chineseToPinYin(this.valueName)
const firstBig = vPinyin.toFirstBig(resultPy)
console.log(firstBig)//ZGR
},
</script>