vuejs中文转拼音,带声符
1、安装
npm install pinyin --save
2、特性
根据词组智能匹配最正确的拼音。
支持多音字。
简单的繁体支持。
支持多种不同拼音风格。
3、用法:
var pinyin = require("pinyin");
console.log(pinyin("中心")); // [ [ 'zhōng' ], [ 'xīn' ] ]
console.log(pinyin("中心", {
heteronym: true // 启用多音字模式
})); // [ [ 'zhōng', 'zhòng' ], [ 'xīn' ] ]
console.log(pinyin("中心", {
heteronym: true, // 启用多音字模式
segment: true // 启用分词,以解决多音字问题。
})); // [ [ 'zhōng' ], [ 'xīn' ] ]
console.log(pinyin("我喜欢你", {
segment: true, // 启用分词
group: true // 启用词组
})); // [ [ 'wǒ' ], [ 'xǐhuān' ], [ 'nǐ' ] ]
console.log(pinyin("中心", {
style: pinyin.STYLE_INITIALS, // 设置拼音风格
heteronym: true
})); // [ [ 'zh' ], [ 'x' ] ]
以上是编程学习网小编为您介绍的“vuejs中文转拼音,带声符”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。