1 Star 2 Fork 1

yinuocode / Convert-Pinyin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test.html 1.86 KB
一键复制 编辑 Web IDE 原始数据 按行查看 历史
yuanqiao 提交于 2021-06-09 13:44 . init
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>获取汉字首字母 js 插件使用</title>
</head>
<body>
<div>
<div>获取字符串第一个字符的首字母</div></div>
<input type="text" onblur="getInitial1(this.value)">
<button>获取首字母</button>
<div id="txt1"></div>
<div style="font-size: 12px; color: #999; margin-top: 20px;">多个字母开头的多音字会显示多个字母</div>
</div>
<div>
<div>获取字符串每个字符的首字母</div></div>
<input type="text" onblur="getInitial2(this.value)">
<button>获取首字母</button>
<div id="txt2"></div>
<div style="font-size: 12px; color: #999; margin-top: 20px;">多个字母开头的多音字会显示多个字母</div>
</div>
<div>
<div>获取字符串拼音</div></div>
<input type="text" onblur="getInitial3(this.value)">
<button>获取首字母</button>
<div id="txt3"></div>
<div style="font-size: 12px; color: #999; margin-top: 20px;">多个字母开头的多音字会显示多个字母</div>
</div>
<script src="./convert-pinyin.js"></script>
<script>
// 返回所有字符的首字母
function getInitial1(str) {
let py = getChineseStrPY(str);
console.log(py);
document.getElementById('txt1').textContent = py;
}
function getInitial2(str) {
// 返回第一个字符的首字母
let py = getChineseStrPY(str, 'first');
console.log(py);
document.getElementById('txt2').textContent = py;
}
// 返回每一个字符的拼音全拼
function getInitial3(str) {
let py = getChineseStrPY(str, 'all');
console.log(py);
document.getElementById('txt3').textContent = py;
}
</script>
</body>
</html>
1
https://gitee.com/yinuocode/convert-pinyin.git
git@gitee.com:yinuocode/convert-pinyin.git
yinuocode
convert-pinyin
Convert-Pinyin
master

搜索帮助

14c37bed 8189591 565d56ea 8189591