feat: 2.2.5 偏旁部首库

This commit is contained in:
tackchen 2020-09-08 18:05:55 +08:00
parent 7c0f09a210
commit 3d2e6185c9
97 changed files with 10602 additions and 799 deletions

220
README.md
View File

@ -54,20 +54,21 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword) * [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword)
* [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.9 汉字、拼音工具方法](#59-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) * [5.9 偏旁部首功能](#59-%E5%81%8F%E6%97%81%E9%83%A8%E9%A6%96%E5%8A%9F%E8%83%BD)
+ [5.9.1 查询拼音详细信息: spellInfo](#591-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo) * [5.10 汉字、拼音工具方法](#510-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
+ [5.9.2 拼音音调操作: transformTone](#592-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone) + [5.10.1 查询拼音详细信息: spellInfo](#5101-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo)
+ [5.9.3 是否是汉字: isCnChar](#593-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar) + [5.10.2 拼音音调操作: transformTone](#5102-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone)
+ [5.9.4 比较拼音(汉字)大小: compareSpell](#594-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell) + [5.10.3 是否是汉字: isCnChar](#5103-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar)
+ [5.9.5 比较汉字笔画数大小: compareStroke](#595-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke) + [5.10.4 比较拼音(汉字)大小: compareSpell](#5104-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell)
+ [5.9.6 根据拼音排序: sortSpell](#596-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell) + [5.10.5 比较汉字笔画数大小: compareStroke](#5105-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke)
+ [5.9.7 根据笔画数排序: sortStroke](#597-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke) + [5.10.6 根据拼音排序: sortSpell](#5106-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell)
* [5.10 其他 api](#510-%E5%85%B6%E4%BB%96-api) + [5.10.7 根据笔画数排序: sortStroke](#5107-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke)
+ [5.10.1 .use()](#5101-use) * [5.11 其他 api](#511-%E5%85%B6%E4%BB%96-api)
+ [5.10.2 .type](#5102-type) + [5.11.1 .use()](#5111-use)
+ [5.10.3 .check](#5103-check) + [5.11.2 .type](#5112-type)
+ [5.10.4 .version](#5104-version) + [5.11.3 .check](#5113-check)
+ [5.10.5 .plugins](#5105-plugins) + [5.11.4 .version](#5114-version)
+ [5.11.5 .plugins](#5115-plugins)
- [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0) - [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0)
* [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0) * [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0)
* [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0) * [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0)
@ -76,24 +77,26 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0) * [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0)
* [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0) * [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0)
* [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0) * [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0)
* [6.8 使用实例大全:](#68-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8) * [6.8 radical 参数](#68-radical-%E5%8F%82%E6%95%B0)
+ [6.8.0 安装使用](#680-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8) * [6.9 使用实例大全:](#69-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8)
+ [6.8.1 cnchar 基础库功能](#681-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.0 安装使用](#690-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8)
+ [6.8.2 cnchar-poly 库功能](#682-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.1 cnchar 基础库功能](#691-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.3 cnchar-order 库功能](#683-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.2 cnchar-poly 库功能](#692-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.4 cnchar-trad 库功能](#684-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.3 cnchar-order 库功能](#693-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.1 convert 字体转换](#6841-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2) + [6.9.4 cnchar-trad 库功能](#694-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.2 spell 和 stroke 方法](#6842-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95) - [6.9.4.1 convert 字体转换](#6941-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2)
+ [6.8.5 cnchar-idiom 库功能](#685-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD) - [6.9.4.2 spell 和 stroke 方法](#6942-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95)
+ [6.8.6 cnchar-xhy 库功能](#686-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.5 cnchar-idiom 库功能](#695-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.7 工具方法](#687-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) + [6.9.6 cnchar-xhy 库功能](#696-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.1 spellInfo](#6871-spellinfo) + [6.9.7 cnchar-radical 库功能](#697-cnchar-radical-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.2 isCnChar](#6872-iscnchar) + [6.9.8 工具方法](#698-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
- [6.8.7.3 transformTone](#6873-transformtone) - [6.9.8.1 spellInfo](#6981-spellinfo)
- [6.8.7.4 compareSpell](#6874-comparespell) - [6.9.8.2 isCnChar](#6982-iscnchar)
- [6.8.7.5 compareStroke](#6875-comparestroke) - [6.9.8.3 transformTone](#6983-transformtone)
- [6.8.7.6 sortSpell](#6876-sortspell) - [6.9.8.4 compareSpell](#6984-comparespell)
- [6.8.7.7 sortStroke](#6877-sortstroke) - [6.9.8.5 compareStroke](#6985-comparestroke)
- [6.9.8.6 sortSpell](#6986-sortspell)
- [6.9.8.7 sortStroke](#6987-sortstroke)
- [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90) - [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90)
<!-- tocstop --> <!-- tocstop -->
@ -162,11 +165,12 @@ import cnchar from 'cnchar';
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
### 2.概览 ### 2.概览
@ -181,6 +185,7 @@ import cnchar from 'cnchar';
| cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ | | cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ |
| cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ | | cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ |
| cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| cnchar-radical | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
### 3.安装 ### 3.安装
@ -195,12 +200,12 @@ npm i cnchar
安装附加功能库: 安装附加功能库:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) 当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的四个 或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的所有插件
``` ```
npm i cnchar-all npm i cnchar-all
@ -215,6 +220,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
或使用以下cdn包含了以上七个库 或使用以下cdn包含了以上七个库
@ -238,6 +244,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// 插件请按需取用 // 插件请按需取用
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
@ -258,9 +265,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// 插件请按需取用 // 插件请按需取用
// 注cnchar-draw 在非浏览器环境下不可使用 // 注cnchar-draw 在非浏览器环境下不可使用
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -280,6 +288,7 @@ console.log(cnchar.spell('汉字')); // cnchar api 调用
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -565,6 +574,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
#### 5.8 歇后语功能 #### 5.8 歇后语功能
cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行 cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行
@ -588,11 +599,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 汉字、拼音工具方法 使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
#### 5.9 偏旁部首功能
cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
#### 5.10 汉字、拼音工具方法
cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字 cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字
##### 5.9.1 查询拼音详细信息: spellInfo ##### 5.10.1 查询拼音详细信息: spellInfo
`spellInfo` 方法用于查询拼音的详细信息,用法如下: `spellInfo` 方法用于查询拼音的详细信息,用法如下:
@ -626,7 +664,7 @@ cnchar.spellInfo.tones;
// n 的一声使用 * 代替 // n 的一声使用 * 代替
``` ```
##### 5.9.2 拼音音调操作: transformTone ##### 5.10.2 拼音音调操作: transformTone
`transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调 `transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调
@ -650,7 +688,7 @@ type 为可选参数表示返回值spell设置大小写默认为 'low'
transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng` transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng`
##### 5.9.3 是否是汉字: isCnChar ##### 5.10.3 是否是汉字: isCnChar
`isCnChar` 方法用于判断一个字符是否是汉字 `isCnChar` 方法用于判断一个字符是否是汉字
@ -658,7 +696,7 @@ transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 比较拼音(汉字)大小: compareSpell ##### 5.10.4 比较拼音(汉字)大小: compareSpell
`compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景 `compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景
@ -679,7 +717,7 @@ cnchar.compareSpell('ao', 'ai') // 返回 'more' 因为 o 排在 i 之后
cnchar.compareSpell('奥', 'ai') // 返回 'more' cnchar.compareSpell('奥', 'ai') // 返回 'more'
``` ```
##### 5.9.5 比较汉字笔画数大小: compareStroke ##### 5.10.5 比较汉字笔画数大小: compareStroke
`compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法 `compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法
@ -699,7 +737,7 @@ cnchar.compareStroke(20, '好') // 返回 'more'
cnchar.compareStroke('一个', '好') // 返回 'less' cnchar.compareStroke('一个', '好') // 返回 'less'
``` ```
##### 5.9.6 根据拼音排序: sortSpell ##### 5.10.6 根据拼音排序: sortSpell
`sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序 `sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序
@ -721,7 +759,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 根据笔画数排序: sortStroke ##### 5.10.7 根据笔画数排序: sortStroke
`sortStroke` 方法用于按照笔画数排序汉字 `sortStroke` 方法用于按照笔画数排序汉字
@ -743,9 +781,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 其他 api #### 5.11 其他 api
##### 5.10.1 .use() ##### 5.11.1 .use()
这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库 这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库
@ -774,9 +812,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord` 参数类型: type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord`、`idiom`、 `xhy`、`radical` 参数类型:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -784,6 +822,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']` spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']`
@ -796,9 +837,17 @@ spellToWordArg 最多可用值: `['simple','trad','poly','alltone','array']`
strokeToWordArg 最多可用值: `['simple','trad','array']` strokeToWordArg 最多可用值: `['simple','trad','array']`
idiomArg 最多可用值: `['char','stroke','spell','tone']`
xhyArg 最多可用值: `['fuzzy','answer','second']`
radicalArg 最多可用值: `['array']`
以上值皆为 json
具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到 具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到
##### 5.10.3 .check ##### 5.11.3 .check
该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true 该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true
@ -808,7 +857,7 @@ strokeToWordArg 最多可用值: `['simple','trad','array']`
cnchar.check = false; // 关闭参数校验 cnchar.check = false; // 关闭参数校验
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
获取当前版本: 获取当前版本:
@ -816,7 +865,7 @@ cnchar.check = false; // 关闭参数校验
var version = cnchar.version; // string 类型 var version = cnchar.version; // string 类型
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]` 当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]`
@ -965,9 +1014,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 | | answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 |
| second | 是否是根据歇后语后一句查询 | 否 | -- | -- | | second | 是否是根据歇后语后一句查询 | 否 | -- | -- |
#### 6.8 使用实例大全: #### 6.8 radical 参数
##### 6.8.0 安装使用 参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
#### 6.9 使用实例大全:
##### 6.9.0 安装使用
npm 方式 npm 方式
@ -989,7 +1050,7 @@ script 标签引用 方式
</script> </script>
``` ```
##### 6.8.1 cnchar 基础库功能 ##### 6.9.1 cnchar 基础库功能
```js ```js
//spell 功能 //spell 功能
@ -1024,7 +1085,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
4. stroke 方法 非中文字符会笔画数会计为 0 4. stroke 方法 非中文字符会笔画数会计为 0
5. stroke 方法 order 模式 非中文字符会返回 undefined 5. stroke 方法 order 模式 非中文字符会返回 undefined
##### 6.8.2 cnchar-poly 库功能 ##### 6.9.2 cnchar-poly 库功能
该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能 该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能
@ -1034,7 +1095,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
'长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order 库功能 ##### 6.9.3 cnchar-order 库功能
该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组 该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组
@ -1090,11 +1151,11 @@ cnchar.orderToWord(['横', '撇', '捺'], 'contain');
// 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的 // 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的
``` ```
##### 6.8.4 cnchar-trad 库功能 ##### 6.9.4 cnchar-trad 库功能
该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持 该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持
###### 6.8.4.1 convert 字体转换 ###### 6.9.4.1 convert 字体转换
```js ```js
'一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad
@ -1116,7 +1177,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell 和 stroke 方法 ###### 6.9.4.2 spell 和 stroke 方法
该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致: 该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致:
@ -1132,7 +1193,7 @@ cnchar.convert.sparkToTrad('①个亾');
'長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]] '長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom 库功能 ##### 6.9.5 cnchar-idiom 库功能
该库为cnchar扩展了成语功能 该库为cnchar扩展了成语功能
@ -1143,7 +1204,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy 库功能 ##### 6.9.6 cnchar-xhy 库功能
该库为cnchar扩展了歇后语功能 该库为cnchar扩展了歇后语功能
@ -1154,18 +1215,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 工具方法 ##### 6.9.7 cnchar-radical 库功能
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 工具方法
cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字 cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1175,7 +1247,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1184,7 +1256,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1196,7 +1268,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1206,7 +1278,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1217,7 +1289,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

View File

@ -28,6 +28,7 @@ module.exports = {
{text: 'cnchar-draw: 汉字可视化', link: '/doc/draw'}, {text: 'cnchar-draw: 汉字可视化', link: '/doc/draw'},
{text: 'cnchar-idiom: 成语', link: '/doc/idiom'}, {text: 'cnchar-idiom: 成语', link: '/doc/idiom'},
{text: 'cnchar-xhy: 歇后语', link: '/doc/xhy'}, {text: 'cnchar-xhy: 歇后语', link: '/doc/xhy'},
{text: 'cnchar-radical: 偏旁部首', link: '/doc/radical'},
{text: '工具方法', link: '/doc/tool'}, {text: '工具方法', link: '/doc/tool'},
], ],
}, },
@ -81,6 +82,10 @@ module.exports = {
title: 'cnchar-xhy', title: 'cnchar-xhy',
path: 'xhy', path: 'xhy',
}, },
{
title: 'cnchar-radical',
path: 'radical',
},
{ {
title: '工具方法', title: '工具方法',
path: 'tool', path: 'tool',

View File

@ -22,6 +22,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
## 2. idiom 参数 ## 2. idiom 参数
参数调用如下value表示查询对象可以试拼音汉字笔画数所有 arg 参数都是可选的 参数调用如下value表示查询对象可以试拼音汉字笔画数所有 arg 参数都是可选的

48
docs/doc/radical.md Normal file
View File

@ -0,0 +1,48 @@
## 1. 介绍
cnchar在2.2.5加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
## 2. radical 参数
参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
## 3. 实例
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```

View File

@ -22,6 +22,8 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
## 2. xhy 参数 ## 2. xhy 参数
参数调用如下value表示歇后语查询对象可以是歇后语的第一句或第二句所有 arg 参数都是可选的 参数调用如下value表示歇后语查询对象可以是歇后语的第一句或第二句所有 arg 参数都是可选的

View File

@ -46,11 +46,12 @@ sidebarDepth: 0 //吐槽这里设置0无效只能设置1或2
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
## 3. 概览 ## 3. 概览
@ -66,6 +67,7 @@ sidebarDepth: 0 //吐槽这里设置0无效只能设置1或2
| [cnchar-draw](/cnchar/v2/doc/draw) | 绘制笔画库 | 支持可视化绘制汉字,有 normal,animation,stroke,test 四种模式可选,该库仅在浏览器环境下可用 | 2.1+ | | [cnchar-draw](/cnchar/v2/doc/draw) | 绘制笔画库 | 支持可视化绘制汉字,有 normal,animation,stroke,test 四种模式可选,该库仅在浏览器环境下可用 | 2.1+ |
| [cnchar-idiom](/cnchar/v2/doc/idiom) | 成语库 | 支持成语查询等功能 | 2.2+ | | [cnchar-idiom](/cnchar/v2/doc/idiom) | 成语库 | 支持成语查询等功能 | 2.2+ |
| [cnchar-xhy](/cnchar/v2/doc/xhy) | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | [cnchar-xhy](/cnchar/v2/doc/xhy) | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| [cnchar-radical](/cnchar/v2/doc/radical) | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
<div> <div>
<star></star> <star></star>

View File

@ -1,7 +1,7 @@
## 1. npm安装 ## 1. npm安装
cnchar包含了一个基本库和六个功能库用于实现不同的功能您可以按需安装其中的功能库但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) cnchar包含了一个基本库和六个功能库用于实现不同的功能您可以按需安装其中的功能库但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
安装[主库](https://npmjs.com/package/cnchar) 安装[主库](https://npmjs.com/package/cnchar)
@ -15,7 +15,7 @@ npm i cnchar
<div> <div>
<highlight-code> <highlight-code>
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
</highlight-code> </highlight-code>
</div> </div>
@ -31,6 +31,7 @@ npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
</highlight-code> </highlight-code>
</div> </div>
@ -45,7 +46,8 @@ npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy
import trad from 'cnchar-trad'; import trad from 'cnchar-trad';
import idiom from 'cnchar-idiom'; import idiom from 'cnchar-idiom';
import xhy from 'cnchar-xhy'; import xhy from 'cnchar-xhy';
cnchar.use(poly, order, trad, idiom, xhy); import radical from 'cnchar-radical';
cnchar.use(poly, order, trad, idiom, xhy, radical);
</highlight-code> </highlight-code>
</div> </div>
@ -60,7 +62,8 @@ commonjs 模块
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
cnchar.use(poly, order, trad, idiom, xhy); var radical = require('cnchar-radical');
cnchar.use(poly, order, trad, idiom, xhy, radical);
</highlight-code> </highlight-code>
</div> </div>
@ -77,6 +80,7 @@ commonjs 模块
&lt;script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js">&lt;/script> &lt;script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js">&lt;/script>
&lt;script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js">&lt;/script> &lt;script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js">&lt;/script>
&lt;script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"> &lt;/script> &lt;script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"> &lt;/script>
&lt;script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"> &lt;/script>
&lt;script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"> &lt;/script> &lt;script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"> &lt;/script>
</highlight-code> </highlight-code>
</div> </div>

View File

@ -80,7 +80,7 @@
1. 修复cnchar-all及cnchar-draw库在非浏览器环境会报错的bug 1. 修复cnchar-all及cnchar-draw库在非浏览器环境会报错的bug
2. 修复 draw库和main库在ts环境中引用的异常 2. 修复 draw库和main库在ts环境中引用的异常
## 2.2.0 [2020/6/4] ## 2.2.0
1. 增加cnchar-idiom 成语库 1. 增加cnchar-idiom 成语库
2. 增加cnchar-xhy 歇后语库 2. 增加cnchar-xhy 歇后语库
3. 增加transformTone,isCnchar,compareSpell,compareStroke,sortSpell,sortStroke工具方法方便开发者更便捷的操作拼音和汉字 3. 增加transformTone,isCnchar,compareSpell,compareStroke,sortSpell,sortStroke工具方法方便开发者更便捷的操作拼音和汉字
@ -89,3 +89,20 @@
6. 彷徨读音修正 6. 彷徨读音修正
7. cnchar-draw 增加 Promise-polyfill 7. cnchar-draw 增加 Promise-polyfill
8. 文档增加Object.assign-polyfill 8. 文档增加Object.assign-polyfill
## 2.2.1
1. 修复ts声明文件的bug
2. ts声明文件增加字符串扩展方法
3. 修复构建npm的bug
## 2.2.2
1. 增加几个多音字的默认读音
## 2.2.3
1. 修复draw库不同绘制实例样式会干扰的bug
## 2.2.4
1. 增加 红 字的默认读音
## 2.2.5
1. 增加cnchar-radical, 偏旁部首插件库

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[15],{634:function(r,t,n){"use strict";n.r(t);var a=n(21),c=Object(a.a)({},(function(){var r=this,t=r.$createElement,n=r._self._c||t;return n("ContentSlotsDistributor",{attrs:{"slot-key":r.$parent.slotKey}},[n("h2",{attrs:{id:"_1-介绍"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_1-介绍"}},[r._v("#")]),r._v(" 1. 介绍")]),r._v(" "),n("p",[n("code",[r._v("cnchar-trad")]),r._v(" 库是用于繁体字,除此之外,该库还提供繁体、简体、火星文之间的相互转换")]),r._v(" "),n("p",[r._v("引入该库之后cnchar的所有api都支持 "),n("code",[r._v("simple")]),r._v("和"),n("code",[r._v("trad")]),r._v("参数,用于只使用简体或繁体,默认两种字体都使用")]),r._v(" "),n("p",[r._v("npm安装")]),r._v(" "),n("div",[n("highlight-code",[r._v("\nnpm i cnchar-trad\n ")])],1),r._v(" "),n("p",[r._v("cdn使用")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"html"}},[r._v('\n<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"><\/script>\n ')])],1),r._v(" "),n("p",[r._v("使用")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"javascript"}},[r._v("\nimport cnchar from 'cnchar';\nimport trad from 'cnchar-trad';\ncnchar.use(trad); // use 在浏览器环境中非必须\n ")])],1),r._v(" "),n("h2",{attrs:{id:"_2-繁体字支持"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_2-繁体字支持"}},[r._v("#")]),r._v(" 2. 繁体字支持")]),r._v(" "),n("p",[r._v("以下演示几个繁体字支持的例子")]),r._v(" "),n("div",[n("codebox",{attrs:{id:"trad"}})],1),r._v(" "),n("h2",{attrs:{id:"_3-字体转换-convert"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_3-字体转换-convert"}},[r._v("#")]),r._v(" 3. 字体转换(convert)")]),r._v(" "),n("p",[r._v("引入 cnchar-trad 库之后在cnchar上会生成一个 "),n("code",[r._v("convert")]),r._v(" 对象功能是支持字体转换另外在string.prototype 上也会附加上对应的方法,用法如下:")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"javascript"}},[r._v("\ncnchar.convert.simpleToTrad(string); // 简体 => 繁体\ncnchar.convert.simpleToSpark(string); // 简体 => 火星文\ncnchar.convert.tradToSimple(string); // 繁体 => 简体\ncnchar.convert.tradToSpark(string); // 繁体 => 火星文\ncnchar.convert.sparkToSimple(string); // 火星文 => 简体\ncnchar.convert.sparkToTrad(string); // 火星文 => 繁体\nstring.convertSimpleToTrad();\nstring.convertSimpleToSpark();\nstring.convertTradToSimple();\nstring.convertTradToSpark();\nstring.convertSparkToSimple();\nstring.convertSparkToTrad();\n ")])],1),r._v(" "),n("p",[r._v("以下是几个实例:")]),r._v(" "),n("div",[n("codebox",{attrs:{id:"convert"}})],1)])}),[],!1,null,null,null);t.default=c.exports}}]); (window.webpackJsonp=window.webpackJsonp||[]).push([[16],{636:function(r,t,n){"use strict";n.r(t);var a=n(21),c=Object(a.a)({},(function(){var r=this,t=r.$createElement,n=r._self._c||t;return n("ContentSlotsDistributor",{attrs:{"slot-key":r.$parent.slotKey}},[n("h2",{attrs:{id:"_1-介绍"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_1-介绍"}},[r._v("#")]),r._v(" 1. 介绍")]),r._v(" "),n("p",[n("code",[r._v("cnchar-trad")]),r._v(" 库是用于繁体字,除此之外,该库还提供繁体、简体、火星文之间的相互转换")]),r._v(" "),n("p",[r._v("引入该库之后cnchar的所有api都支持 "),n("code",[r._v("simple")]),r._v("和"),n("code",[r._v("trad")]),r._v("参数,用于只使用简体或繁体,默认两种字体都使用")]),r._v(" "),n("p",[r._v("npm安装")]),r._v(" "),n("div",[n("highlight-code",[r._v("\nnpm i cnchar-trad\n ")])],1),r._v(" "),n("p",[r._v("cdn使用")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"html"}},[r._v('\n<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"><\/script>\n ')])],1),r._v(" "),n("p",[r._v("使用")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"javascript"}},[r._v("\nimport cnchar from 'cnchar';\nimport trad from 'cnchar-trad';\ncnchar.use(trad); // use 在浏览器环境中非必须\n ")])],1),r._v(" "),n("h2",{attrs:{id:"_2-繁体字支持"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_2-繁体字支持"}},[r._v("#")]),r._v(" 2. 繁体字支持")]),r._v(" "),n("p",[r._v("以下演示几个繁体字支持的例子")]),r._v(" "),n("div",[n("codebox",{attrs:{id:"trad"}})],1),r._v(" "),n("h2",{attrs:{id:"_3-字体转换-convert"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_3-字体转换-convert"}},[r._v("#")]),r._v(" 3. 字体转换(convert)")]),r._v(" "),n("p",[r._v("引入 cnchar-trad 库之后在cnchar上会生成一个 "),n("code",[r._v("convert")]),r._v(" 对象功能是支持字体转换另外在string.prototype 上也会附加上对应的方法,用法如下:")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"javascript"}},[r._v("\ncnchar.convert.simpleToTrad(string); // 简体 => 繁体\ncnchar.convert.simpleToSpark(string); // 简体 => 火星文\ncnchar.convert.tradToSimple(string); // 繁体 => 简体\ncnchar.convert.tradToSpark(string); // 繁体 => 火星文\ncnchar.convert.sparkToSimple(string); // 火星文 => 简体\ncnchar.convert.sparkToTrad(string); // 火星文 => 繁体\nstring.convertSimpleToTrad();\nstring.convertSimpleToSpark();\nstring.convertTradToSimple();\nstring.convertTradToSpark();\nstring.convertSparkToSimple();\nstring.convertSparkToTrad();\n ")])],1),r._v(" "),n("p",[r._v("以下是几个实例:")]),r._v(" "),n("div",[n("codebox",{attrs:{id:"convert"}})],1)])}),[],!1,null,null,null);t.default=c.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[18],{628:function(r,c,n){"use strict";n.r(c);var a=n(21),t=Object(a.a)({},(function(){var r=this,c=r.$createElement,n=r._self._c||c;return n("ContentSlotsDistributor",{attrs:{"slot-key":r.$parent.slotKey}},[n("h2",{attrs:{id:"_1-npm安装"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_1-npm安装"}},[r._v("#")]),r._v(" 1. npm安装")]),r._v(" "),n("p",[r._v("cnchar包含了一个基本库和六个功能库用于实现不同的功能您可以按需安装其中的功能库但是 "),n("code",[r._v("cnchar")]),r._v(" 这个基础库是必须安装的draw、idiom、xhy三个库可以独立使用")]),r._v(" "),n("p",[r._v("安装"),n("a",{attrs:{href:"https://npmjs.com/package/cnchar",target:"_blank",rel:"noopener noreferrer"}},[r._v("主库"),n("OutboundLink")],1),r._v("")]),r._v(" "),n("div",[n("highlight-code",[r._v("\nnpm i cnchar\n ")])],1),r._v(" "),n("p",[r._v("按需安装功能库:")]),r._v(" "),n("div",[n("highlight-code",[r._v("\nnpm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy\n ")])],1),r._v(" "),n("p",[r._v("浏览器环境中功能库可以直接使用:")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"javascript"}},[r._v("\n import cnchar from 'cnchar';\n // 以下功能库请按需使用\n import 'cnchar-poly';\n import 'cnchar-order';\n import 'cnchar-trad';\n import 'cnchar-draw';\n import 'cnchar-idiom';\n import 'cnchar-xhy';\n ")])],1),r._v(" "),n("p",[r._v("非浏览器环境中功能库需要使用use方法加载且不支持 "),n("code",[r._v("cnchar-draw")]),r._v(" 库:")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"javascript"}},[r._v("\n import cnchar from 'cnchar';\n // 以下功能库请按需使用\n import poly from 'cnchar-poly';\n import order from 'cnchar-order';\n import trad from 'cnchar-trad';\n import idiom from 'cnchar-idiom';\n import xhy from 'cnchar-xhy';\n cnchar.use(poly, order, trad, idiom, xhy);\n ")])],1),r._v(" "),n("p",[r._v("commonjs 模块")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"javascript"}},[r._v("\n var cnchar = require('cnchar');\n // 以下功能库请按需使用\n var poly = require('cnchar-poly');\n var order = require('cnchar-order');\n var trad = require('cnchar-trad');\n var idiom = require('cnchar-idiom');\n var xhy = require('cnchar-xhy');\n cnchar.use(poly, order, trad, idiom, xhy);\n ")])],1),r._v(" "),n("h2",{attrs:{id:"_2-cdn引用"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_2-cdn引用"}},[r._v("#")]),r._v(" 2. CDN引用")]),r._v(" "),n("p",[r._v("使用 script 标签使用:")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"html"}},[r._v('\n <script src="https://cdn.jsdelivr.net/npm/cnchar/cnchar.min.js"><\/script>\n \x3c!--以下功能库请按需使用--\x3e\n <script src="https://cdn.jsdelivr.net/npm/cnchar-poly/cnchar.poly.min.js"><\/script>\n <script src="https://cdn.jsdelivr.net/npm/cnchar-order/cnchar.order.min.js"><\/script>\n <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"><\/script>\n <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"><\/script>\n <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"> <\/script>\n <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"> <\/script>\n ')])],1),r._v(" "),n("h2",{attrs:{id:"_3-cnchar-all"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_3-cnchar-all"}},[r._v("#")]),r._v(" 3. cnchar-all")]),r._v(" "),n("p",[r._v("如果您需要使用cnchar及其插件的所有功能可以通过安装"),n("code",[r._v("cnchar-all")]),r._v("来使用完整功能,这个库引用了上面的七个库")]),r._v(" "),n("div",[n("highlight-code",[r._v("\nnpm i cnchar-all\n ")])],1),r._v(" "),n("p",[r._v("commonjs 模块")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"javascript"}},[r._v("\n import cnchar from 'cnchar-all';\n ")])],1),r._v(" "),n("p",[r._v("cdn方式")]),r._v(" "),n("div",[n("highlight-code",{attrs:{lang:"html"}},[r._v('\n <script src="https://cdn.jsdelivr.net/npm/cnchar-all/cnchar.all.min.js"><\/script>\n ')])],1),r._v(" "),n("h2",{attrs:{id:"_4-简单使用"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#_4-简单使用"}},[r._v("#")]),r._v(" 4. 简单使用")]),r._v(" "),n("p",[r._v("cnchar 具有两个最核心的方法"),n("code",[r._v("spell")]),r._v(" 和 "),n("code",[r._v("stroke")]),r._v(",分别用于获取汉字的拼音和笔画数:")]),r._v(" "),n("div",[n("codebox",{attrs:{id:"easy-use",title:"spell/stroke"}})],1),r._v(" "),n("p",[r._v("这只是一个最简单的使用,这两个方法具有很多参数可选,具体请参阅 "),n("a",{attrs:{href:"/cnchar/v2/doc/cnchar"}},[r._v("cnchar")]),r._v(" 部分")])])}),[],!1,null,null,null);c.default=t.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[21],{516:function(n,w,o){}}]);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[22],{516:function(n,w,o){}}]);

View File

@ -1 +0,0 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[22],{620:function(n,w,o){}}]);

View File

@ -0,0 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[23],{620:function(n,w,o){}}]);

View File

@ -1,4 +1,4 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[23],{619:function(e,t,n){ (window.webpackJsonp=window.webpackJsonp||[]).push([[24],{619:function(e,t,n){
/*! /*!
* Valine v1.4.4 * Valine v1.4.4
* (c) 2017-2020 xCss * (c) 2017-2020 xCss

View File

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{540:function(t,s,a){},615:function(t,s,a){t.exports=a.p+"assets/img/logo.6cd28633.png"},616:function(t,s,a){"use strict";var i=a(540);a.n(i).a},625:function(t,s,a){"use strict";a.r(s);var i=[function(){var t=this.$createElement,s=this._self._c||t;return s("div",[s("img",{staticClass:"logo",attrs:{src:a(615),alt:"",srcset:""}})])},function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"feature-w"},[a("div",{staticClass:"f-i"},[a("div",{staticClass:"f-t"},[a("i",{staticClass:"ei-rocket"}),t._v("功能全面")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("拼音、笔画数")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("多音字词")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("繁体字、火星文")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("汉字笔顺")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("多种模式绘制汉字")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("汉字推算")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("...")])]),t._v(" "),a("div",{staticClass:"f-i"},[a("div",{staticClass:"f-t"},[a("i",{staticClass:"ei-tablet"}),t._v("多端支持")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("浏览器")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("nodejs")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("小程序/小游戏")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("ReactNative/Weex/Uniapp/Electron")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("webpack")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("typescript支持")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("...")])]),t._v(" "),a("div",{staticClass:"f-i"},[a("div",{staticClass:"f-t"},[a("i",{staticClass:"ei-cubes"}),t._v("按需取用")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("功能分包")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("体积小巧")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("简单易用")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("npm")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("cdn")])])])},function(){var t=this.$createElement,s=this._self._c||t;return s("div",{staticClass:"copy-right"},[this._v("MIT Licensed | Copyright © 2020 present "),s("a",{attrs:{href:"https://www.github.com/theajack",target:"view_window"}},[this._v("theajack")])])}],e=(a(201),a(40),a(59),a(96),{data:function(){return{text:"",spell:"",stroke:"",trad:"",spark:"",order:""}},methods:{input:function(){if(this.text){this.spell=this.text.spell("array","tone").join(" "),this.stroke=this.text.stroke(),this.trad=this.text.convertSimpleToTrad("trad"),this.spark=this.text.convertSimpleToSpark("spark"),this.order=JSON.stringify(this.text.stroke("order","shape")).replace(/"/g,"").replace(/null/g,"无");var t=this.pickCnChar(this.text),s=document.getElementById("draw-area");s.innerHTML="",""!==t&&window.cnchar.draw(t,{el:s})}},isCnChar:function(t){var s=t.charCodeAt(0);return s>=19968&&s<=40869},pickCnChar:function(t){for(var s="",a=0;a<t.length;a++)this.isCnChar(t[a])&&(s+=t[a]);return s},start:function(){window.location.href="/cnchar/v2/guide/"}},mounted:function(){var t=setInterval((function(){var s=document.getElementById("vcomments");s&&(s.className+=" home-comment",clearInterval(t))}),500)}}),v=(a(616),a(21)),r=Object(v.a)(e,(function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"home-wrapper"},[t._m(0),t._v(" "),a("div",{staticClass:"title"},[t._v("cnchar")]),t._v(" "),a("div",{staticClass:"desc"},[t._v("功能全面、多端支持的汉字拼音笔画js库")]),t._v(" "),a("div",{staticClass:"test"},[a("el-input",{staticClass:"test-input",attrs:{type:"text",placeholder:"输入一些汉字试试"},on:{input:t.input},model:{value:t.text,callback:function(s){t.text=s},expression:"text"}}),t._v(" "),a("div",{directives:[{name:"show",rawName:"v-show",value:""!==t.text,expression:'text!==""'}],staticClass:"show-area"},[a("div",[t._v(t._s(t.spell)+" "),a("span",{staticClass:"split"},[t._v("|")]),t._v(" 共"+t._s(t.stroke)+"笔")]),t._v(" "),a("div",[t._v("繁体: "+t._s(t.trad)+" "),a("span",{staticClass:"split"},[t._v("|")]),t._v(" 火星文: "+t._s(t.spark))]),t._v(" "),a("div",[t._v("笔顺: "+t._s(t.order))]),t._v(" "),a("div",{attrs:{id:"draw-area"}})])],1),t._v(" "),a("div",{staticClass:"start-w"},[a("el-button",{attrs:{type:"primary"},on:{click:t.start}},[t._v("开始 "),a("i",{staticClass:"ei-location-arrow"})])],1),t._v(" "),t._m(1),t._v(" "),t._m(2)])}),i,!1,null,null,null);s.default=r.exports}}]); (window.webpackJsonp=window.webpackJsonp||[]).push([[4],{540:function(t,s,a){},615:function(t,s,a){t.exports=a.p+"assets/img/logo.6cd28633.png"},616:function(t,s,a){"use strict";var i=a(540);a.n(i).a},626:function(t,s,a){"use strict";a.r(s);var i=[function(){var t=this.$createElement,s=this._self._c||t;return s("div",[s("img",{staticClass:"logo",attrs:{src:a(615),alt:"",srcset:""}})])},function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"feature-w"},[a("div",{staticClass:"f-i"},[a("div",{staticClass:"f-t"},[a("i",{staticClass:"ei-rocket"}),t._v("功能全面")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("拼音、笔画数")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("多音字词")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("繁体字、火星文")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("汉字笔顺")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("多种模式绘制汉字")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("汉字推算")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("...")])]),t._v(" "),a("div",{staticClass:"f-i"},[a("div",{staticClass:"f-t"},[a("i",{staticClass:"ei-tablet"}),t._v("多端支持")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("浏览器")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("nodejs")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("小程序/小游戏")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("ReactNative/Weex/Uniapp/Electron")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("webpack")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("typescript支持")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("...")])]),t._v(" "),a("div",{staticClass:"f-i"},[a("div",{staticClass:"f-t"},[a("i",{staticClass:"ei-cubes"}),t._v("按需取用")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("功能分包")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("体积小巧")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("简单易用")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("npm")]),t._v(" "),a("div",{staticClass:"f-des"},[t._v("cdn")])])])},function(){var t=this.$createElement,s=this._self._c||t;return s("div",{staticClass:"copy-right"},[this._v("MIT Licensed | Copyright © 2020 present "),s("a",{attrs:{href:"https://www.github.com/theajack",target:"view_window"}},[this._v("theajack")])])}],e=(a(201),a(40),a(59),a(96),{data:function(){return{text:"",spell:"",stroke:"",trad:"",spark:"",order:""}},methods:{input:function(){if(this.text){this.spell=this.text.spell("array","tone").join(" "),this.stroke=this.text.stroke(),this.trad=this.text.convertSimpleToTrad("trad"),this.spark=this.text.convertSimpleToSpark("spark"),this.order=JSON.stringify(this.text.stroke("order","shape")).replace(/"/g,"").replace(/null/g,"无");var t=this.pickCnChar(this.text),s=document.getElementById("draw-area");s.innerHTML="",""!==t&&window.cnchar.draw(t,{el:s})}},isCnChar:function(t){var s=t.charCodeAt(0);return s>=19968&&s<=40869},pickCnChar:function(t){for(var s="",a=0;a<t.length;a++)this.isCnChar(t[a])&&(s+=t[a]);return s},start:function(){window.location.href="/cnchar/v2/guide/"}},mounted:function(){var t=setInterval((function(){var s=document.getElementById("vcomments");s&&(s.className+=" home-comment",clearInterval(t))}),500)}}),v=(a(616),a(21)),r=Object(v.a)(e,(function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"home-wrapper"},[t._m(0),t._v(" "),a("div",{staticClass:"title"},[t._v("cnchar")]),t._v(" "),a("div",{staticClass:"desc"},[t._v("功能全面、多端支持的汉字拼音笔画js库")]),t._v(" "),a("div",{staticClass:"test"},[a("el-input",{staticClass:"test-input",attrs:{type:"text",placeholder:"输入一些汉字试试"},on:{input:t.input},model:{value:t.text,callback:function(s){t.text=s},expression:"text"}}),t._v(" "),a("div",{directives:[{name:"show",rawName:"v-show",value:""!==t.text,expression:'text!==""'}],staticClass:"show-area"},[a("div",[t._v(t._s(t.spell)+" "),a("span",{staticClass:"split"},[t._v("|")]),t._v(" 共"+t._s(t.stroke)+"笔")]),t._v(" "),a("div",[t._v("繁体: "+t._s(t.trad)+" "),a("span",{staticClass:"split"},[t._v("|")]),t._v(" 火星文: "+t._s(t.spark))]),t._v(" "),a("div",[t._v("笔顺: "+t._s(t.order))]),t._v(" "),a("div",{attrs:{id:"draw-area"}})])],1),t._v(" "),a("div",{staticClass:"start-w"},[a("el-button",{attrs:{type:"primary"},on:{click:t.start}},[t._v("开始 "),a("i",{staticClass:"ei-location-arrow"})])],1),t._v(" "),t._m(1),t._v(" "),t._m(2)])}),i,!1,null,null,null);s.default=r.exports}}]);

View File

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{541:function(t,s,i){},617:function(t,s,i){"use strict";var n=i(541);i.n(n).a},626:function(t,s,i){"use strict";i.r(s);var n={methods:{starGithub:function(){window.open("https://github.com/1011cat/shotCat_doc")}}},a=(i(617),i(21)),c=Object(a.a)(n,(function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"bg",on:{click:this.starGithub}},[this._m(0)])}),[function(){var t=this.$createElement,s=this._self._c||t;return s("div",{staticClass:"word glitch"},[s("div",{staticClass:"flash is-off"},[s("span",{staticClass:"text"},[this._v("给个star!")])])])}],!1,null,null,null);s.default=c.exports}}]); (window.webpackJsonp=window.webpackJsonp||[]).push([[5],{541:function(t,s,i){},617:function(t,s,i){"use strict";var n=i(541);i.n(n).a},625:function(t,s,i){"use strict";i.r(s);var n={methods:{starGithub:function(){window.open("https://github.com/1011cat/shotCat_doc")}}},a=(i(617),i(21)),c=Object(a.a)(n,(function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"bg",on:{click:this.starGithub}},[this._m(0)])}),[function(){var t=this.$createElement,s=this._self._c||t;return s("div",{staticClass:"word glitch"},[s("div",{staticClass:"flash is-off"},[s("span",{staticClass:"text"},[this._v("给个star!")])])])}],!1,null,null,null);s.default=c.exports}}]);

View File

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{542:function(t,e,n){},618:function(t,e,n){"use strict";var i=n(542);n.n(i).a},639:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(618),n(21)),a=Object(r.a)(i,void 0,void 0,!1,null,"15b7b770",null);e.default=a.exports}}]); (window.webpackJsonp=window.webpackJsonp||[]).push([[6],{542:function(t,e,n){},618:function(t,e,n){"use strict";var i=n(542);n.n(i).a},632:function(t,e,n){"use strict";n.r(e);var i={functional:!0,props:{type:{type:String,default:"tip"},text:String,vertical:{type:String,default:"top"}},render:function(t,e){var n=e.props,i=e.slots;return t("span",{class:["badge",n.type],style:{verticalAlign:n.vertical}},n.text||i().default)}},r=(n(618),n(21)),a=Object(r.a)(i,void 0,void 0,!1,null,"15b7b770",null);e.default=a.exports}}]);

View File

@ -1 +1 @@
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{636:function(t,e,n){"use strict";n.r(e);var s=n(21),o=Object(s.a)({},(function(){var t=this.$createElement,e=this._self._c||t;return e("ContentSlotsDistributor",{attrs:{"slot-key":this.$parent.slotKey}},[e("div",[e("home")],1)])}),[],!1,null,null,null);e.default=o.exports}}]); (window.webpackJsonp=window.webpackJsonp||[]).push([[8],{634:function(t,e,n){"use strict";n.r(e);var s=n(21),o=Object(s.a)({},(function(){var t=this.$createElement,e=this._self._c||t;return e("ContentSlotsDistributor",{attrs:{"slot-key":this.$parent.slotKey}},[e("div",[e("home")],1)])}),[],!1,null,null,null);e.default=o.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,7 @@
<meta name="generator" content="VuePress 1.4.0"> <meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico"> <link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.b0052b42.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/9.a1c7f0bf.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.6fe8a37b.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.afec1f15.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.d168a5e4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.0ea02f06.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4dd87a78.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.ad93db03.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.b4b4c0f9.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.56e78ae6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.43f4edea.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.1bd42485.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.45301e81.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.fdca0c28.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.c736cefc.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.fcf3f00c.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.39b1109a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.7bf56da2.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.c52e8de4.js"> <link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/9.18ff6ea2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.5f7eeac4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.077923da.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.793898e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4b7779c5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.7f808694.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.a5cba3ff.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.f46096eb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.828d46cb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.fe6aa719.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css"> <link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head> </head>
<body> <body>
@ -32,6 +32,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -60,6 +62,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -68,7 +72,7 @@
Gitee地址 Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号 CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="active sidebar-link">cnchar</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_2-spell-" class="sidebar-link">2. spell </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_3-stroke-" class="sidebar-link">3. stroke </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_4-" class="sidebar-link">4. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_5-" class="sidebar-link">5. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_6-api" class="sidebar-link">6. api</a></li></ul></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p>cnchar <code></code> <code></code> </p> <p> <code></code>, <code></code>, <code></code> </p> <p>ts<a href="https://github.com/theajack/cnchar/blob/master/src/main/index.d.ts" target="_blank" rel="noopener noreferrer">cnchar.d.ts<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <h2 id="_2-spell-"><a href="#_2-spell-" class="header-anchor">#</a> 2. spell </h2> <p>spell </p> <h3 id="_2-1-api使"><a href="#_2-1-api使" class="header-anchor">#</a> 2.1. api使</h3> <p>api arg </p> <div><pre><code class="hljs javascript">cnchar.spell(string,arg1,arg2,...); <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="active sidebar-link">cnchar</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_2-spell-" class="sidebar-link">2. spell </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_3-stroke-" class="sidebar-link">3. stroke </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_4-" class="sidebar-link">4. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_5-" class="sidebar-link">5. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/cnchar.html#_6-api" class="sidebar-link">6. api</a></li></ul></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/radical.html" class="sidebar-link">cnchar-radical</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p>cnchar <code></code> <code></code> </p> <p> <code></code>, <code></code>, <code></code> </p> <p>ts<a href="https://github.com/theajack/cnchar/blob/master/src/main/index.d.ts" target="_blank" rel="noopener noreferrer">cnchar.d.ts<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <h2 id="_2-spell-"><a href="#_2-spell-" class="header-anchor">#</a> 2. spell </h2> <p>spell </p> <h3 id="_2-1-api使"><a href="#_2-1-api使" class="header-anchor">#</a> 2.1. api使</h3> <p>api arg </p> <div><pre><code class="hljs javascript">cnchar.spell(string,arg1,arg2,...);
string.spell(arg1,arg2,...); <span class="hljs-comment">// string prototype 调用</span></code></pre></div> <p>以下是几个简单的例子:</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>spell</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70> string.spell(arg1,arg2,...); <span class="hljs-comment">// string prototype 调用</span></code></pre></div> <p>以下是几个简单的例子:</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>spell</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70>
Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <h3 id="_2-2-"><a href="#_2-2-" class="header-anchor">#</a> 2.2. </h3> <p>arg </p> <table><thead><tr><th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th></tr></thead> <tbody><tr><td style="text-align:center;">array</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">first</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">up</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">low</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;"> up </td></tr> <tr><td style="text-align:center;">poly</td> <td style="text-align:center;">使</td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">tone</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">simple</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">cnchar-trad</td> <td style="text-align:center;">使 cnchar-trad </td></tr></tbody></table> <h2 id="_3-stroke-"><a href="#_3-stroke-" class="header-anchor">#</a> 3. stroke </h2> <h3 id="_2-1-api使-2"><a href="#_2-1-api使-2" class="header-anchor">#</a> 2.1. api使</h3> <p>api arg </p> <div><pre><code class="hljs javascript">cnchar.stroke(string,arg1,arg2,...); Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <h3 id="_2-2-"><a href="#_2-2-" class="header-anchor">#</a> 2.2. </h3> <p>arg </p> <table><thead><tr><th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th></tr></thead> <tbody><tr><td style="text-align:center;">array</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">first</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">up</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">low</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;"> up </td></tr> <tr><td style="text-align:center;">poly</td> <td style="text-align:center;">使</td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">tone</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">simple</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">cnchar-trad</td> <td style="text-align:center;">使 cnchar-trad </td></tr></tbody></table> <h2 id="_3-stroke-"><a href="#_3-stroke-" class="header-anchor">#</a> 3. stroke </h2> <h3 id="_2-1-api使-2"><a href="#_2-1-api使-2" class="header-anchor">#</a> 2.1. api使</h3> <p>api arg </p> <div><pre><code class="hljs javascript">cnchar.stroke(string,arg1,arg2,...);
string.stroke(arg1,arg2,...); <span class="hljs-comment">// string prototype 调用</span></code></pre></div> <p>以下是几个简单的例子:</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>stroke</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70> string.stroke(arg1,arg2,...); <span class="hljs-comment">// string prototype 调用</span></code></pre></div> <p>以下是几个简单的例子:</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>stroke</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70>
@ -92,6 +96,6 @@ cnchar.use(poly, order, trad); <span class="hljs-comment">// 参数顺序无关
</a> </a>
</span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div> </span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.b0052b42.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/9.a1c7f0bf.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script> <script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/9.18ff6ea2.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,7 @@
<meta name="generator" content="VuePress 1.4.0"> <meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico"> <link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.b0052b42.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/11.afec1f15.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.6fe8a37b.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.d168a5e4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.0ea02f06.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4dd87a78.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.ad93db03.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.b4b4c0f9.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.56e78ae6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.43f4edea.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.1bd42485.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.45301e81.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.fdca0c28.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.c736cefc.js"><link rel="prefetch" href="/cnchar/v2/assets/js/3.21c3e3be.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.fcf3f00c.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.39b1109a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.7bf56da2.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.c52e8de4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.a1c7f0bf.js"> <link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/11.5f7eeac4.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.077923da.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.793898e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4b7779c5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.7f808694.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.a5cba3ff.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.f46096eb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/3.21c3e3be.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.828d46cb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.fe6aa719.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.18ff6ea2.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css"> <link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head> </head>
<body> <body>
@ -32,6 +32,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -60,6 +62,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -68,7 +72,7 @@
Gitee地址 Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号 CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="active sidebar-link">cnchar-idiom</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/idiom.html#_1-" class="sidebar-link">1 </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/idiom.html#_2-idiom-" class="sidebar-link">2. idiom </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/idiom.html#_3-" class="sidebar-link">3. </a></li></ul></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1 </h2> <p>cnchar2.2.0 <code>cnchar-idiom</code> cnchar</p> <p>使</p> <div class="language-ts extra-class"><pre class="language-ts"><code>cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span>text<span class="token operator">:</span><span class="token builtin">string</span><span class="token punctuation">,</span> <span class="token operator">...</span>idiomArgs<span class="token operator">:</span> <span class="token builtin">Array</span><span class="token operator">&lt;</span>idiomArg<span class="token operator">&gt;</span><span class="token punctuation">)</span><span class="token operator">:</span><span class="token builtin">Array</span><span class="token operator">&lt;</span><span class="token builtin">string</span><span class="token operator">&gt;</span><span class="token punctuation">;</span> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="active sidebar-link">cnchar-idiom</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/idiom.html#_1-" class="sidebar-link">1 </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/idiom.html#_2-idiom-" class="sidebar-link">2. idiom </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/idiom.html#_3-" class="sidebar-link">3. </a></li></ul></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/radical.html" class="sidebar-link">cnchar-radical</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1 </h2> <p>cnchar2.2.0 <code>cnchar-idiom</code> cnchar</p> <p>使</p> <div class="language-ts extra-class"><pre class="language-ts"><code>cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span>text<span class="token operator">:</span><span class="token builtin">string</span><span class="token punctuation">,</span> <span class="token operator">...</span>idiomArgs<span class="token operator">:</span> <span class="token builtin">Array</span><span class="token operator">&lt;</span>idiomArg<span class="token operator">&gt;</span><span class="token punctuation">)</span><span class="token operator">:</span><span class="token builtin">Array</span><span class="token operator">&lt;</span><span class="token builtin">string</span><span class="token operator">&gt;</span><span class="token punctuation">;</span>
</code></pre></div><p></p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// </span> </code></pre></div><p></p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// </span>
cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// ['', '']</span> cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// ['', '']</span>
<span class="token comment">// 根据笔画数查询成语0表示匹配任意笔画末尾的0可以省略</span> <span class="token comment">// 根据笔画数查询成语0表示匹配任意笔画末尾的0可以省略</span>
@ -77,7 +81,7 @@ cnchar<span class="token punctuation">.</span><span class="token function">idiom
cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token string">'shang'</span><span class="token punctuation">,</span> <span class="token string">'spell'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [&quot;&quot;, &quot;&quot;, ...]</span> cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token string">'shang'</span><span class="token punctuation">,</span> <span class="token string">'spell'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [&quot;&quot;, &quot;&quot;, ...]</span>
<span class="token comment">// 带音调</span> <span class="token comment">// 带音调</span>
cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token string">'shang4'</span><span class="token punctuation">,</span> <span class="token string">'spell'</span><span class="token punctuation">,</span> <span class="token string">'tone'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [&quot;&quot;, &quot;&quot;, ... ]</span> cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token string">'shang4'</span><span class="token punctuation">,</span> <span class="token string">'spell'</span><span class="token punctuation">,</span> <span class="token string">'tone'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [&quot;&quot;, &quot;&quot;, ... ]</span>
</code></pre></div><h2 id="_2-idiom-"><a href="#_2-idiom-" class="header-anchor">#</a> 2. idiom </h2> <p>value arg </p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span>arg1<span class="token punctuation">,</span>arg2<span class="token punctuation">,</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span> </code></pre></div><p>使cdnwindow <code>CncharIdiom</code> </p> <h2 id="_2-idiom-"><a href="#_2-idiom-" class="header-anchor">#</a> 2. idiom </h2> <p>value arg </p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span>arg1<span class="token punctuation">,</span>arg2<span class="token punctuation">,</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div><table><thead><tr><th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th></tr></thead> <tbody><tr><td style="text-align:center;">char</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;"></td></tr> <tr><td style="text-align:center;">stroke</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">char</td></tr> <tr><td style="text-align:center;">spell</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">stroke</td></tr> <tr><td style="text-align:center;">tone</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">spell</td></tr></tbody></table> <p> <code>spell</code> &gt; <code>stroke</code> &gt; <code>char</code></p> <h2 id="_3-"><a href="#_3-" class="header-anchor">#</a> 3. </h2> <p>cnchar</p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token comment">// ['', '']</span> </code></pre></div><table><thead><tr><th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th></tr></thead> <tbody><tr><td style="text-align:center;">char</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;"></td></tr> <tr><td style="text-align:center;">stroke</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">char</td></tr> <tr><td style="text-align:center;">spell</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">stroke</td></tr> <tr><td style="text-align:center;">tone</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">spell</td></tr></tbody></table> <p> <code>spell</code> &gt; <code>stroke</code> &gt; <code>char</code></p> <h2 id="_3-"><a href="#_3-" class="header-anchor">#</a> 3. </h2> <p>cnchar</p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token comment">// ['', '']</span>
cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'stroke'</span><span class="token punctuation">)</span> <span class="token comment">// ['']</span> cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token number">4</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">6</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'stroke'</span><span class="token punctuation">)</span> <span class="token comment">// ['']</span>
cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token string">'shang'</span><span class="token punctuation">,</span> <span class="token string">'spell'</span><span class="token punctuation">)</span> <span class="token comment">// ['', '', ... ]</span> cnchar<span class="token punctuation">.</span><span class="token function">idiom</span><span class="token punctuation">(</span><span class="token string">'shang'</span><span class="token punctuation">,</span> <span class="token string">'spell'</span><span class="token punctuation">)</span> <span class="token comment">// ['', '', ... ]</span>
@ -91,6 +95,6 @@ cnchar<span class="token punctuation">.</span><span class="token function">idiom
</a> </a>
</span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div> </span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.b0052b42.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/11.afec1f15.js" defer></script> <script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/11.5f7eeac4.js" defer></script>
</body> </body>
</html> </html>

View File

@ -8,7 +8,7 @@
<meta name="generator" content="VuePress 1.4.0"> <meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico"> <link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.b0052b42.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/12.d168a5e4.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.6fe8a37b.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.afec1f15.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.0ea02f06.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4dd87a78.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.ad93db03.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.b4b4c0f9.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.56e78ae6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.43f4edea.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.1bd42485.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.45301e81.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.fdca0c28.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.c736cefc.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.fcf3f00c.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.39b1109a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.7bf56da2.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.c52e8de4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.a1c7f0bf.js"> <link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/12.077923da.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.5f7eeac4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.793898e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4b7779c5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.7f808694.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.a5cba3ff.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.f46096eb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.828d46cb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.fe6aa719.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.18ff6ea2.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css"> <link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head> </head>
<body> <body>
@ -32,6 +32,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -60,6 +62,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -68,7 +72,7 @@
Gitee地址 Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号 CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="active sidebar-link">cnchar-order</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/order.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/order.html#_2-stroke" class="sidebar-link">2. stroke</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/order.html#_3-" class="sidebar-link">3. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/order.html#_4--ordertoword" class="sidebar-link">4. (orderToWord)</a></li></ul></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p><code>cnchar-order</code> <code>orderToWord</code>json</p> <p><code>cnchar.stroke()</code> <code>order</code> </p> <p>npm</p> <div><pre><code class="hljs">npm i cnchar-order</code></pre></div> <p>cdn使</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-order/cnchar.order.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <p>使</p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>; <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="active sidebar-link">cnchar-order</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/order.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/order.html#_2-stroke" class="sidebar-link">2. stroke</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/order.html#_3-" class="sidebar-link">3. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/order.html#_4--ordertoword" class="sidebar-link">4. (orderToWord)</a></li></ul></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/radical.html" class="sidebar-link">cnchar-radical</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p><code>cnchar-order</code> <code>orderToWord</code>json</p> <p><code>cnchar.stroke()</code> <code>order</code> </p> <p>npm</p> <div><pre><code class="hljs">npm i cnchar-order</code></pre></div> <p>cdn使</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-order/cnchar.order.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <p>使</p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>;
<span class="hljs-keyword">import</span> order <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-order'</span>; <span class="hljs-keyword">import</span> order <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-order'</span>;
cnchar.use(order); <span class="hljs-comment">// use 在浏览器环境中非必须</span></code></pre></div> <h2 id="_2-stroke参数"><a href="#_2-stroke参数" class="header-anchor">#</a> 2. stroke参数</h2> <table><thead><tr><th style="text-align:center;">参数</th> <th style="text-align:center;">作用</th> <th style="text-align:center;">是否默认</th> <th style="text-align:center;">依赖库</th> <th style="text-align:center;">备注</th></tr></thead> <tbody><tr><td style="text-align:center;">array</td> <td style="text-align:center;">返回数组</td> <td style="text-align:center;">否</td> <td style="text-align:center;">--</td> <td style="text-align:center;">使用 cnchar-order 且启用 order 参数后该参数被忽略</td></tr> <tr><td style="text-align:center;">order</td> <td style="text-align:center;">启用笔画顺序</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">letter</td> <td style="text-align:center;">使用笔画顺序字母序列</td> <td style="text-align:center;">是</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">当启用 order 后,该值是默认值</td></tr> <tr><td style="text-align:center;">detail</td> <td style="text-align:center;">使用笔画顺序详情作为返回值,每个汉字对应一个 json</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">优先级小于 letter</td></tr> <tr><td style="text-align:center;">shape</td> <td style="text-align:center;">使用笔画形状作为返回值</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">优先级小于 detail</td></tr> <tr><td style="text-align:center;">name</td> <td style="text-align:center;">使用笔画名称作为返回值</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">优先级小于 shape</td></tr> <tr><td style="text-align:center;">count</td> <td style="text-align:center;">使用笔画数作为返回值</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-poly</td> <td style="text-align:center;">优先级小于 name</td></tr> <tr><td style="text-align:center;">simple</td> <td style="text-align:center;">是否禁用繁体字的笔画功能</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-trad</td> <td style="text-align:center;">使用 cnchar-trad 之后,默认对繁体字启用笔画功能,该参数用于禁用繁体字笔画功能</td></tr></tbody></table> <p>以上五种模式优先级为 <strong>letter &lt; detail &lt; shape &lt; name &lt; count</strong></p> <h2 id="_3-实例"><a href="#_3-实例" class="header-anchor">#</a> 3. 实例</h2> <p>以下演示几个多音词的例子</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>order</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70> cnchar.use(order); <span class="hljs-comment">// use 在浏览器环境中非必须</span></code></pre></div> <h2 id="_2-stroke参数"><a href="#_2-stroke参数" class="header-anchor">#</a> 2. stroke参数</h2> <table><thead><tr><th style="text-align:center;">参数</th> <th style="text-align:center;">作用</th> <th style="text-align:center;">是否默认</th> <th style="text-align:center;">依赖库</th> <th style="text-align:center;">备注</th></tr></thead> <tbody><tr><td style="text-align:center;">array</td> <td style="text-align:center;">返回数组</td> <td style="text-align:center;">否</td> <td style="text-align:center;">--</td> <td style="text-align:center;">使用 cnchar-order 且启用 order 参数后该参数被忽略</td></tr> <tr><td style="text-align:center;">order</td> <td style="text-align:center;">启用笔画顺序</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">--</td></tr> <tr><td style="text-align:center;">letter</td> <td style="text-align:center;">使用笔画顺序字母序列</td> <td style="text-align:center;">是</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">当启用 order 后,该值是默认值</td></tr> <tr><td style="text-align:center;">detail</td> <td style="text-align:center;">使用笔画顺序详情作为返回值,每个汉字对应一个 json</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">优先级小于 letter</td></tr> <tr><td style="text-align:center;">shape</td> <td style="text-align:center;">使用笔画形状作为返回值</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">优先级小于 detail</td></tr> <tr><td style="text-align:center;">name</td> <td style="text-align:center;">使用笔画名称作为返回值</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-order</td> <td style="text-align:center;">优先级小于 shape</td></tr> <tr><td style="text-align:center;">count</td> <td style="text-align:center;">使用笔画数作为返回值</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-poly</td> <td style="text-align:center;">优先级小于 name</td></tr> <tr><td style="text-align:center;">simple</td> <td style="text-align:center;">是否禁用繁体字的笔画功能</td> <td style="text-align:center;">否</td> <td style="text-align:center;">cnchar-trad</td> <td style="text-align:center;">使用 cnchar-trad 之后,默认对繁体字启用笔画功能,该参数用于禁用繁体字笔画功能</td></tr></tbody></table> <p>以上五种模式优先级为 <strong>letter &lt; detail &lt; shape &lt; name &lt; count</strong></p> <h2 id="_3-实例"><a href="#_3-实例" class="header-anchor">#</a> 3. 实例</h2> <p>以下演示几个多音词的例子</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>order</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70>
Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <p>shape iosmacos</p> <h2 id="_4--ordertoword"><a href="#_4--ordertoword" class="header-anchor">#</a> 4. (orderToWord)</h2> <h3 id="_4-1-使"><a href="#_4-1-使" class="header-anchor">#</a> 4.1 使</h3> <p> <code>cnchar-order</code> ( 2.0.2 )cnchar 使</p> <div><pre><code class="hljs javascript">cnchar.orderToWord(orderNames[,...args]);</code></pre></div> <p><code>orderNames</code> , </p> <p><code>args</code> <code>['match','matchorder','contain','start','array','simple']</code>, 使 <code>cnchar.type.orderToWord</code> 4.2</p> <p>使</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>orderToWord</span> <span class="code-desc" data-v-0175ad70></span> <i title="线" class="ei-play code-btn" data-v-0175ad70></i> <i title="" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70></div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70></span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70> Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <p>shape iosmacos</p> <h2 id="_4--ordertoword"><a href="#_4--ordertoword" class="header-anchor">#</a> 4. (orderToWord)</h2> <h3 id="_4-1-使"><a href="#_4-1-使" class="header-anchor">#</a> 4.1 使</h3> <p> <code>cnchar-order</code> ( 2.0.2 )cnchar 使</p> <div><pre><code class="hljs javascript">cnchar.orderToWord(orderNames[,...args]);</code></pre></div> <p><code>orderNames</code> , </p> <p><code>args</code> <code>['match','matchorder','contain','start','array','simple']</code>, 使 <code>cnchar.type.orderToWord</code> 4.2</p> <p>使</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>orderToWord</span> <span class="code-desc" data-v-0175ad70></span> <i title="线" class="ei-play code-btn" data-v-0175ad70></i> <i title="" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70></div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70></span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70>
@ -83,6 +87,6 @@ cnchar.use(order); <span class="hljs-comment">// use 在浏览器环境中非必
</a> </a>
</span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div> </span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.b0052b42.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/12.d168a5e4.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script> <script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/12.077923da.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script>
</body> </body>
</html> </html>

View File

@ -8,7 +8,7 @@
<meta name="generator" content="VuePress 1.4.0"> <meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico"> <link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.b0052b42.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/13.356e982d.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.6fe8a37b.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.afec1f15.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.d168a5e4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.0ea02f06.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4dd87a78.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.ad93db03.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.b4b4c0f9.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.56e78ae6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.43f4edea.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.1bd42485.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.45301e81.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.fdca0c28.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.c736cefc.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.fcf3f00c.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.39b1109a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.7bf56da2.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.c52e8de4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.a1c7f0bf.js"> <link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/13.356e982d.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.5f7eeac4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.077923da.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.793898e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4b7779c5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.7f808694.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.a5cba3ff.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.f46096eb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.828d46cb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.fe6aa719.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.18ff6ea2.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css"> <link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head> </head>
<body> <body>
@ -32,6 +32,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -60,6 +62,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -68,7 +72,7 @@
Gitee地址 Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号 CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="active sidebar-link">cnchar-poly</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/poly.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/poly.html#_2-" class="sidebar-link">2. </a></li></ul></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p><code>cnchar-poly</code> api</p> <p><code>cnchar.spell()</code> </p> <p>npm</p> <div><pre><code class="hljs">npm i cnchar-poly</code></pre></div> <p>cdn使</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-poly/cnchar.poly.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <p>使</p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>; <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="active sidebar-link">cnchar-poly</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/poly.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/poly.html#_2-" class="sidebar-link">2. </a></li></ul></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/radical.html" class="sidebar-link">cnchar-radical</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p><code>cnchar-poly</code> api</p> <p><code>cnchar.spell()</code> </p> <p>npm</p> <div><pre><code class="hljs">npm i cnchar-poly</code></pre></div> <p>cdn使</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-poly/cnchar.poly.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <p>使</p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>;
<span class="hljs-keyword">import</span> poly <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-poly'</span>; <span class="hljs-keyword">import</span> poly <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-poly'</span>;
cnchar.use(poly); <span class="hljs-comment">// use 在浏览器环境中非必须</span></code></pre></div> <h2 id="_2-实例"><a href="#_2-实例" class="header-anchor">#</a> 2. 实例</h2> <p>以下演示几个多音词的例子</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>poly</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70> cnchar.use(poly); <span class="hljs-comment">// use 在浏览器环境中非必须</span></code></pre></div> <h2 id="_2-实例"><a href="#_2-实例" class="header-anchor">#</a> 2. 实例</h2> <p>以下演示几个多音词的例子</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>poly</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70>
Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <p>cncharjs</p> <p><a href="https://github.com/theajack/cnchar/issues/new" target="_blank" rel="noopener noreferrer">issuepr<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">:</span> <span class="time">4/14/2020, 1:02:43 AM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev"> Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <p>cncharjs</p> <p><a href="https://github.com/theajack/cnchar/issues/new" target="_blank" rel="noopener noreferrer">issuepr<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">:</span> <span class="time">4/14/2020, 1:02:43 AM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
@ -80,6 +84,6 @@ cnchar.use(poly); <span class="hljs-comment">// use 在浏览器环境中非必
</a> </a>
</span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div> </span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.b0052b42.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/13.356e982d.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script> <script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/13.356e982d.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script>
</body> </body>
</html> </html>

98
docs/v2/doc/radical.html Normal file
View File

@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>1. 介绍 | cnchar</title>
<meta name="description" content="功能全面、多端支持的汉字拼音笔画js库">
<meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/14.793898e3.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.5f7eeac4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.077923da.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4b7779c5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.7f808694.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.a5cba3ff.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.f46096eb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/3.21c3e3be.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.828d46cb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.fe6aa719.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.18ff6ea2.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head>
<body>
<div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/cnchar/v2/" class="home-link router-link-active"><!----> <span class="site-name">cnchar</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/cnchar/v2/" class="nav-link">
主页
</a></div><div class="nav-item"><a href="/cnchar/v2/guide/" class="nav-link">
使用说明
</a></div><div class="nav-item"><a href="https://www.github.com/theajack/cnchar" target="_blank" rel="noopener noreferrer" class="nav-link external">
GitHub
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/cnchar.html" class="nav-link">
cnchar: 拼音+笔画
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/poly.html" class="nav-link">
cnchar-poly: 多音词
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/order.html" class="nav-link">
cnchar-order: 笔顺
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/trad.html" class="nav-link">
cnchar-trad: 繁体字
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/draw.html" class="nav-link">
cnchar-draw: 汉字可视化
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/idiom.html" class="nav-link">
cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link router-link-exact-active router-link-active">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
GitHub地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="http://www.gitee.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/cnchar/v2/" class="nav-link">
主页
</a></div><div class="nav-item"><a href="/cnchar/v2/guide/" class="nav-link">
使用说明
</a></div><div class="nav-item"><a href="https://www.github.com/theajack/cnchar" target="_blank" rel="noopener noreferrer" class="nav-link external">
GitHub
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/cnchar.html" class="nav-link">
cnchar: 拼音+笔画
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/poly.html" class="nav-link">
cnchar-poly: 多音词
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/order.html" class="nav-link">
cnchar-order: 笔顺
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/trad.html" class="nav-link">
cnchar-trad: 繁体字
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/draw.html" class="nav-link">
cnchar-draw: 汉字可视化
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/idiom.html" class="nav-link">
cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link router-link-exact-active router-link-active">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
GitHub地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="http://www.gitee.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/radical.html" class="active sidebar-link">cnchar-radical</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/radical.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/radical.html#_2-radical-" class="sidebar-link">2. radical </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/radical.html#_3-" class="sidebar-link">3. </a></li></ul></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p>cnchar2.2.5 <code>cnchar-radical</code> cnchar</p> <p> <code>kewell-tsao</code> pr</p> <p>使</p> <div class="language-ts extra-class"><pre class="language-ts"><code>cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span>text<span class="token operator">:</span><span class="token builtin">string</span> <span class="token operator">|</span> <span class="token builtin">Array</span><span class="token operator">&lt;</span><span class="token builtin">string</span><span class="token operator">&gt;</span><span class="token punctuation">,</span> <span class="token operator">...</span>radicalArgs<span class="token operator">:</span> <span class="token builtin">Array</span><span class="token operator">&lt;</span>radicalArg<span class="token operator">&gt;</span><span class="token punctuation">)</span><span class="token operator">:</span> <span class="token builtin">string</span> <span class="token operator">|</span> <span class="token builtin">Array</span><span class="token operator">&lt;</span><span class="token builtin">string</span><span class="token operator">&gt;</span><span class="token punctuation">;</span>
</code></pre></div><p></p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;&quot;,</span>
cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;&quot;</span>
<span class="token comment">// 返回数组</span>
cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'array'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [&quot;&quot;, &quot;&quot;, &quot;&quot;]</span>
<span class="token comment">// 传入数组会默认返回数组</span>
cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">&quot;&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [&quot;&quot;, &quot;&quot;, &quot;&quot;]</span>
</code></pre></div><p>使cdnwindow <code>CncharRadical</code> </p> <h2 id="_2-radical-"><a href="#_2-radical-" class="header-anchor">#</a> 2. radical </h2> <p>value</p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span>arg1<span class="token punctuation">,</span>arg2<span class="token punctuation">,</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div><table><thead><tr><th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th></tr></thead> <tbody><tr><td style="text-align:center;">array</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;"></td></tr></tbody></table> <h2 id="_3-"><a href="#_3-" class="header-anchor">#</a> 3. </h2> <p>cnchar</p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;&quot;,</span>
cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &quot;&quot;</span>
cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'array'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [&quot;&quot;, &quot;&quot;, &quot;&quot;]</span>
cnchar<span class="token punctuation">.</span><span class="token function">radical</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">&quot;&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// [&quot;&quot;, &quot;&quot;, &quot;&quot;]</span>
</code></pre></div></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/cnchar/v2/doc/xhy.html" class="prev">
cnchar-xhy
</a></span> <span class="next"><a href="/cnchar/v2/doc/tool.html">
工具方法
</a>
</span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/14.793898e3.js" defer></script>
</body>
</html>

View File

@ -8,7 +8,7 @@
<meta name="generator" content="VuePress 1.4.0"> <meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico"> <link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.b0052b42.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/14.0ea02f06.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.6fe8a37b.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.afec1f15.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.d168a5e4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4dd87a78.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.ad93db03.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.b4b4c0f9.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.56e78ae6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.43f4edea.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.1bd42485.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.45301e81.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.fdca0c28.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.c736cefc.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.fcf3f00c.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.39b1109a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.7bf56da2.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.c52e8de4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.a1c7f0bf.js"> <link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/15.4b7779c5.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.5f7eeac4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.077923da.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.793898e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.7f808694.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.a5cba3ff.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.f46096eb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.828d46cb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.fe6aa719.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.18ff6ea2.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css"> <link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head> </head>
<body> <body>
@ -32,6 +32,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link router-link-exact-active router-link-active"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link router-link-exact-active router-link-active">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -60,6 +62,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link router-link-exact-active router-link-active"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link router-link-exact-active router-link-active">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -68,7 +72,7 @@
Gitee地址 Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号 CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/tool.html" class="active sidebar-link"></a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_2--spellinfo" class="sidebar-link">2 : spellInfo</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_3--transformtone" class="sidebar-link">3. : transformTone</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_4--iscnchar" class="sidebar-link">4. : isCnChar</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_5--comparespell" class="sidebar-link">5. : compareSpell</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_6--comparestroke" class="sidebar-link">6. : compareStroke</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_7--sortspell" class="sidebar-link">7. : sortSpell</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_8--sortstroke" class="sidebar-link">8. : sortStroke</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p>cnchar 使便便</p> <h2 id="_2--spellinfo"><a href="#_2--spellinfo" class="header-anchor">#</a> 2 : spellInfo</h2> <h3 id="_2-1-api使"><a href="#_2-1-api使" class="header-anchor">#</a> 2.1 api使</h3> <p><code>spellInfo</code> </p> <div><pre><code class="hljs javascript">cnchar.spellInfo(spell);</code></pre></div> <p>json</p> <div><pre><code class="hljs json">{ <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/radical.html" class="sidebar-link">cnchar-radical</a></li><li><a href="/cnchar/v2/doc/tool.html" class="active sidebar-link"></a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_2--spellinfo" class="sidebar-link">2 : spellInfo</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_3--transformtone" class="sidebar-link">3. : transformTone</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_4--iscnchar" class="sidebar-link">4. : isCnChar</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_5--comparespell" class="sidebar-link">5. : compareSpell</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_6--comparestroke" class="sidebar-link">6. : compareStroke</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_7--sortspell" class="sidebar-link">7. : sortSpell</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/tool.html#_8--sortstroke" class="sidebar-link">8. : sortStroke</a></li></ul></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p>cnchar 使便便</p> <h2 id="_2--spellinfo"><a href="#_2--spellinfo" class="header-anchor">#</a> 2 : spellInfo</h2> <h3 id="_2-1-api使"><a href="#_2-1-api使" class="header-anchor">#</a> 2.1 api使</h3> <p><code>spellInfo</code> </p> <div><pre><code class="hljs javascript">cnchar.spellInfo(spell);</code></pre></div> <p>json</p> <div><pre><code class="hljs json">{
<span class="hljs-attr">"spell"</span>: string, <span class="hljs-comment">// 去音调的拼音小写</span> <span class="hljs-attr">"spell"</span>: string, <span class="hljs-comment">// 去音调的拼音小写</span>
<span class="hljs-attr">"tone"</span>: number, <span class="hljs-comment">// 音调 0-5</span> <span class="hljs-attr">"tone"</span>: number, <span class="hljs-comment">// 音调 0-5</span>
<span class="hljs-attr">"index"</span>: number, <span class="hljs-comment">// 音调位置</span> <span class="hljs-attr">"index"</span>: number, <span class="hljs-comment">// 音调位置</span>
@ -135,9 +139,9 @@ cnchar<span class="token punctuation">.</span><span class="token function">sortS
cnchar<span class="token punctuation">.</span><span class="token function">sortStroke</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'desc'</span><span class="token punctuation">)</span> <span class="token comment">// ['', '', '']</span> cnchar<span class="token punctuation">.</span><span class="token function">sortStroke</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">]</span><span class="token punctuation">,</span> <span class="token string">'desc'</span><span class="token punctuation">)</span> <span class="token comment">// ['', '', '']</span>
</code></pre></div></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">:</span> <span class="time">6/4/2020, 2:06:00 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev"> </code></pre></div></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">:</span> <span class="time">6/4/2020, 2:06:00 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
<a href="/cnchar/v2/doc/xhy.html" class="prev"> <a href="/cnchar/v2/doc/radical.html" class="prev">
cnchar-xhy cnchar-radical
</a></span> <!----></p></div> </main></div><div class="global-ui"><!----><div></div></div></div> </a></span> <!----></p></div> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.b0052b42.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/14.0ea02f06.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script> <script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/15.4b7779c5.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script>
</body> </body>
</html> </html>

View File

@ -8,7 +8,7 @@
<meta name="generator" content="VuePress 1.4.0"> <meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico"> <link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.b0052b42.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/15.4dd87a78.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.6fe8a37b.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.afec1f15.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.d168a5e4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.0ea02f06.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.ad93db03.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.b4b4c0f9.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.56e78ae6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.43f4edea.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.1bd42485.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.45301e81.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.fdca0c28.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.c736cefc.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.fcf3f00c.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.39b1109a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.7bf56da2.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.c52e8de4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.a1c7f0bf.js"> <link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/16.7f808694.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.5f7eeac4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.077923da.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.793898e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4b7779c5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.a5cba3ff.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.f46096eb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.828d46cb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.fe6aa719.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.18ff6ea2.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css"> <link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head> </head>
<body> <body>
@ -32,6 +32,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -60,6 +62,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -68,7 +72,7 @@
Gitee地址 Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号 CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="active sidebar-link">cnchar-trad</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/trad.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/trad.html#_2-" class="sidebar-link">2. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/trad.html#_3--convert" class="sidebar-link">3. (convert)</a></li></ul></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p><code>cnchar-trad</code> </p> <p>cncharapi <code>simple</code><code>trad</code>使使</p> <p>npm</p> <div><pre><code class="hljs">npm i cnchar-trad</code></pre></div> <p>cdn使</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <p>使</p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>; <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="active sidebar-link">cnchar-trad</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/trad.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/trad.html#_2-" class="sidebar-link">2. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/trad.html#_3--convert" class="sidebar-link">3. (convert)</a></li></ul></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="sidebar-link">cnchar-xhy</a></li><li><a href="/cnchar/v2/doc/radical.html" class="sidebar-link">cnchar-radical</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p><code>cnchar-trad</code> </p> <p>cncharapi <code>simple</code><code>trad</code>使使</p> <p>npm</p> <div><pre><code class="hljs">npm i cnchar-trad</code></pre></div> <p>cdn使</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <p>使</p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>;
<span class="hljs-keyword">import</span> trad <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-trad'</span>; <span class="hljs-keyword">import</span> trad <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-trad'</span>;
cnchar.use(trad); <span class="hljs-comment">// use 在浏览器环境中非必须</span></code></pre></div> <h2 id="_2-繁体字支持"><a href="#_2-繁体字支持" class="header-anchor">#</a> 2. 繁体字支持</h2> <p>以下演示几个繁体字支持的例子</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>trad</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70> cnchar.use(trad); <span class="hljs-comment">// use 在浏览器环境中非必须</span></code></pre></div> <h2 id="_2-繁体字支持"><a href="#_2-繁体字支持" class="header-anchor">#</a> 2. 繁体字支持</h2> <p>以下演示几个繁体字支持的例子</p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>trad</span> <span class="code-desc" data-v-0175ad70></span> <i title="在线运行" class="ei-play code-btn" data-v-0175ad70></i> <i title="复制代码" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70>运行结果</div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70>隐藏结果</span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70>
Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <h2 id="_3--convert"><a href="#_3--convert" class="header-anchor">#</a> 3. (convert)</h2> <p> cnchar-trad cnchar <code>convert</code> string.prototype </p> <div><pre><code class="hljs javascript">cnchar.convert.simpleToTrad(string); <span class="hljs-comment">// =&gt; </span> Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <h2 id="_3--convert"><a href="#_3--convert" class="header-anchor">#</a> 3. (convert)</h2> <p> cnchar-trad cnchar <code>convert</code> string.prototype </p> <div><pre><code class="hljs javascript">cnchar.convert.simpleToTrad(string); <span class="hljs-comment">// =&gt; </span>
@ -92,6 +96,6 @@ string.convertSparkToTrad();</code></pre></div> <p>以下是几个实例:</p>
</a> </a>
</span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div> </span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.b0052b42.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/15.4dd87a78.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script> <script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/16.7f808694.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script>
</body> </body>
</html> </html>

View File

@ -8,7 +8,7 @@
<meta name="generator" content="VuePress 1.4.0"> <meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico"> <link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.b0052b42.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/16.ad93db03.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.6fe8a37b.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.afec1f15.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.d168a5e4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.0ea02f06.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4dd87a78.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.b4b4c0f9.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.56e78ae6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.43f4edea.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.1bd42485.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.45301e81.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.fdca0c28.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.c736cefc.js"><link rel="prefetch" href="/cnchar/v2/assets/js/3.21c3e3be.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.fcf3f00c.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.39b1109a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.7bf56da2.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.c52e8de4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.a1c7f0bf.js"> <link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/17.a5cba3ff.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.5f7eeac4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.077923da.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.793898e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4b7779c5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.7f808694.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.f46096eb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/3.21c3e3be.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.828d46cb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.fe6aa719.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.18ff6ea2.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css"> <link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head> </head>
<body> <body>
@ -32,6 +32,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link router-link-exact-active router-link-active"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link router-link-exact-active router-link-active">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -60,6 +62,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link router-link-exact-active router-link-active"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link router-link-exact-active router-link-active">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -68,7 +72,7 @@
Gitee地址 Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号 CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="active sidebar-link">cnchar-xhy</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/xhy.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/xhy.html#_2-xhy-" class="sidebar-link">2. xhy </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/xhy.html#_3-" class="sidebar-link">3. </a></li></ul></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p>cnchar2.2.0 <code>cnchar-xhy</code> cnchar</p> <p>使</p> <div class="language-ts extra-class"><pre class="language-ts"><code>cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span>text<span class="token operator">:</span><span class="token builtin">string</span><span class="token punctuation">,</span> <span class="token operator">...</span>xhyArgs<span class="token operator">:</span> <span class="token builtin">Array</span><span class="token operator">&lt;</span>xhyArg<span class="token operator">&gt;</span><span class="token punctuation">)</span><span class="token operator">:</span><span class="token builtin">Array</span><span class="token operator">&lt;</span><span class="token builtin">string</span><span class="token operator">&gt;</span><span class="token punctuation">;</span> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>cnchar</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/doc/cnchar.html" class="sidebar-link">cnchar</a></li><li><a href="/cnchar/v2/doc/poly.html" class="sidebar-link">cnchar-poly</a></li><li><a href="/cnchar/v2/doc/order.html" class="sidebar-link">cnchar-order</a></li><li><a href="/cnchar/v2/doc/trad.html" class="sidebar-link">cnchar-trad</a></li><li><a href="/cnchar/v2/doc/draw.html" class="sidebar-link">cnchar-draw</a></li><li><a href="/cnchar/v2/doc/idiom.html" class="sidebar-link">cnchar-idiom</a></li><li><a href="/cnchar/v2/doc/xhy.html" class="active sidebar-link">cnchar-xhy</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/xhy.html#_1-" class="sidebar-link">1. </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/xhy.html#_2-xhy-" class="sidebar-link">2. xhy </a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/doc/xhy.html#_3-" class="sidebar-link">3. </a></li></ul></li><li><a href="/cnchar/v2/doc/radical.html" class="sidebar-link">cnchar-radical</a></li><li><a href="/cnchar/v2/doc/tool.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-"><a href="#_1-" class="header-anchor">#</a> 1. </h2> <p>cnchar2.2.0 <code>cnchar-xhy</code> cnchar</p> <p>使</p> <div class="language-ts extra-class"><pre class="language-ts"><code>cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span>text<span class="token operator">:</span><span class="token builtin">string</span><span class="token punctuation">,</span> <span class="token operator">...</span>xhyArgs<span class="token operator">:</span> <span class="token builtin">Array</span><span class="token operator">&lt;</span>xhyArg<span class="token operator">&gt;</span><span class="token punctuation">)</span><span class="token operator">:</span><span class="token builtin">Array</span><span class="token operator">&lt;</span><span class="token builtin">string</span><span class="token operator">&gt;</span><span class="token punctuation">;</span>
</code></pre></div><p></p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// </span> </code></pre></div><p></p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">// </span>
cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// ['-', '-'],</span> cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// ['-', '-'],</span>
<span class="token comment">// 模糊查询</span> <span class="token comment">// 模糊查询</span>
@ -77,7 +81,7 @@ cnchar<span class="token punctuation">.</span><span class="token function">xhy</
cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'fuzzy'</span><span class="token punctuation">,</span> <span class="token string">'answer'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// ['', '', ... ]</span> cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'fuzzy'</span><span class="token punctuation">,</span> <span class="token string">'answer'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// ['', '', ... ]</span>
<span class="token comment">// 根据歇后语后一句查询</span> <span class="token comment">// 根据歇后语后一句查询</span>
cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'fuzzy'</span><span class="token punctuation">,</span> <span class="token string">'answer'</span><span class="token punctuation">,</span> <span class="token string">'second'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// ['', '']</span> cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'fuzzy'</span><span class="token punctuation">,</span> <span class="token string">'answer'</span><span class="token punctuation">,</span> <span class="token string">'second'</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// ['', '']</span>
</code></pre></div><h2 id="_2-xhy-"><a href="#_2-xhy-" class="header-anchor">#</a> 2. xhy </h2> <p>value arg </p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span>arg1<span class="token punctuation">,</span>arg2<span class="token punctuation">,</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span> </code></pre></div><p>使cdnwindow <code>CncharXHY</code> </p> <h2 id="_2-xhy-"><a href="#_2-xhy-" class="header-anchor">#</a> 2. xhy </h2> <p>value arg </p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span>value<span class="token punctuation">,</span>arg1<span class="token punctuation">,</span>arg2<span class="token punctuation">,</span><span class="token operator">...</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre></div><table><thead><tr><th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th></tr></thead> <tbody><tr><td style="text-align:center;">fuzzy</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;"></td></tr> <tr><td style="text-align:center;">answer</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;"></td></tr> <tr><td style="text-align:center;">second</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr></tbody></table> <h2 id="_3-"><a href="#_3-" class="header-anchor">#</a> 3. </h2> <p>cnchar</p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span> <span class="token comment">// ['-', '-']</span> </code></pre></div><table><thead><tr><th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th> <th style="text-align:center;"></th></tr></thead> <tbody><tr><td style="text-align:center;">fuzzy</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;"></td></tr> <tr><td style="text-align:center;">answer</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;"></td></tr> <tr><td style="text-align:center;">second</td> <td style="text-align:center;"></td> <td style="text-align:center;"></td> <td style="text-align:center;">--</td> <td style="text-align:center;">--</td></tr></tbody></table> <h2 id="_3-"><a href="#_3-" class="header-anchor">#</a> 3. </h2> <p>cnchar</p> <div class="language-js extra-class"><pre class="language-js"><code>cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">)</span> <span class="token comment">// ['-', '-']</span>
cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'fuzzy'</span><span class="token punctuation">)</span> <span class="token comment">// ['-', '-', ... ]</span> cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'fuzzy'</span><span class="token punctuation">)</span> <span class="token comment">// ['-', '-', ... ]</span>
cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'fuzzy'</span><span class="token punctuation">,</span> <span class="token string">'answer'</span><span class="token punctuation">)</span> <span class="token comment">// ['', '', ... ]</span> cnchar<span class="token punctuation">.</span><span class="token function">xhy</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">'fuzzy'</span><span class="token punctuation">,</span> <span class="token string">'answer'</span><span class="token punctuation">)</span> <span class="token comment">// ['', '', ... ]</span>
@ -86,11 +90,11 @@ cnchar<span class="token punctuation">.</span><span class="token function">xhy</
<a href="/cnchar/v2/doc/idiom.html" class="prev"> <a href="/cnchar/v2/doc/idiom.html" class="prev">
cnchar-idiom cnchar-idiom
</a></span> <span class="next"><a href="/cnchar/v2/doc/tool.html"> </a></span> <span class="next"><a href="/cnchar/v2/doc/radical.html">
工具方法 cnchar-radical
</a> </a>
</span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div> </span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.b0052b42.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/16.ad93db03.js" defer></script> <script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/17.a5cba3ff.js" defer></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,7 @@
<meta name="generator" content="VuePress 1.4.0"> <meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico"> <link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.b0052b42.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/18.56e78ae6.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.6fe8a37b.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.afec1f15.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.d168a5e4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.0ea02f06.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4dd87a78.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.ad93db03.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.b4b4c0f9.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.43f4edea.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.1bd42485.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.45301e81.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.fdca0c28.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.c736cefc.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.fcf3f00c.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.39b1109a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.7bf56da2.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.c52e8de4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.a1c7f0bf.js"> <link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/19.f46096eb.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/3.21c3e3be.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.5f7eeac4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.077923da.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.793898e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4b7779c5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.7f808694.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.a5cba3ff.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/4.828d46cb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/8.fe6aa719.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.18ff6ea2.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css"> <link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head> </head>
<body> <body>
@ -32,6 +32,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -60,6 +62,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -68,34 +72,38 @@
Gitee地址 Gitee地址
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号 CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>使</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/guide/" class="sidebar-link"></a></li><li><a href="/cnchar/v2/guide/start.html" class="active sidebar-link"></a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/guide/start.html#_1-npm" class="sidebar-link">1. npm</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/guide/start.html#_2-cdn" class="sidebar-link">2. CDN</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/guide/start.html#_3-cnchar-all" class="sidebar-link">3. cnchar-all</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/guide/start.html#_4-使" class="sidebar-link">4. 使</a></li></ul></li><li><a href="/cnchar/v2/guide/version.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-npm"><a href="#_1-npm" class="header-anchor">#</a> 1. npm</h2> <p>cnchar <code>cnchar</code> drawidiomxhy使</p> <p><a href="https://npmjs.com/package/cnchar" target="_blank" rel="noopener noreferrer"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <div><pre><code class="hljs">npm i cnchar</code></pre></div> <p></p> <div><pre><code class="hljs">npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy</code></pre></div> <p>使</p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>; <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>使</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/cnchar/v2/guide/" class="sidebar-link"></a></li><li><a href="/cnchar/v2/guide/start.html" class="active sidebar-link"></a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/cnchar/v2/guide/start.html#_1-npm" class="sidebar-link">1. npm</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/guide/start.html#_2-cdn" class="sidebar-link">2. CDN</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/guide/start.html#_3-cnchar-all" class="sidebar-link">3. cnchar-all</a></li><li class="sidebar-sub-header"><a href="/cnchar/v2/guide/start.html#_4-使" class="sidebar-link">4. 使</a></li></ul></li><li><a href="/cnchar/v2/guide/version.html" class="sidebar-link"></a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h2 id="_1-npm"><a href="#_1-npm" class="header-anchor">#</a> 1. npm</h2> <p>cnchar <code>cnchar</code> drawidiomxhyradical使</p> <p><a href="https://npmjs.com/package/cnchar" target="_blank" rel="noopener noreferrer"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <div><pre><code class="hljs">npm i cnchar</code></pre></div> <p></p> <div><pre><code class="hljs">npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical</code></pre></div> <p>使</p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>;
<span class="hljs-comment">// 以下功能库请按需使用</span> <span class="hljs-comment">// 以下功能库请按需使用</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-poly'</span>; <span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-poly'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-order'</span>; <span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-order'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-trad'</span>; <span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-trad'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-draw'</span>; <span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-draw'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-idiom'</span>; <span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-idiom'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-xhy'</span>;</code></pre></div> <p>使use <code>cnchar-draw</code> </p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>; <span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-xhy'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'cnchar-radical'</span>;</code></pre></div> <p>使use <code>cnchar-draw</code> </p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar'</span>;
<span class="hljs-comment">// 以下功能库请按需使用</span> <span class="hljs-comment">// 以下功能库请按需使用</span>
<span class="hljs-keyword">import</span> poly <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-poly'</span>; <span class="hljs-keyword">import</span> poly <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-poly'</span>;
<span class="hljs-keyword">import</span> order <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-order'</span>; <span class="hljs-keyword">import</span> order <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-order'</span>;
<span class="hljs-keyword">import</span> trad <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-trad'</span>; <span class="hljs-keyword">import</span> trad <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-trad'</span>;
<span class="hljs-keyword">import</span> idiom <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-idiom'</span>; <span class="hljs-keyword">import</span> idiom <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-idiom'</span>;
<span class="hljs-keyword">import</span> xhy <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-xhy'</span>; <span class="hljs-keyword">import</span> xhy <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-xhy'</span>;
cnchar.use(poly, order, trad, idiom, xhy);</code></pre></div> <p>commonjs </p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">var</span> cnchar = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar'</span>); <span class="hljs-keyword">import</span> radical <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-radical'</span>;
cnchar.use(poly, order, trad, idiom, xhy, radical);</code></pre></div> <p>commonjs </p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">var</span> cnchar = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar'</span>);
<span class="hljs-comment">// 以下功能库请按需使用</span> <span class="hljs-comment">// 以下功能库请按需使用</span>
<span class="hljs-keyword">var</span> poly = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-poly'</span>); <span class="hljs-keyword">var</span> poly = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-poly'</span>);
<span class="hljs-keyword">var</span> order = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-order'</span>); <span class="hljs-keyword">var</span> order = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-order'</span>);
<span class="hljs-keyword">var</span> trad = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-trad'</span>); <span class="hljs-keyword">var</span> trad = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-trad'</span>);
<span class="hljs-keyword">var</span> idiom = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-idiom'</span>); <span class="hljs-keyword">var</span> idiom = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-idiom'</span>);
<span class="hljs-keyword">var</span> xhy = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-xhy'</span>); <span class="hljs-keyword">var</span> xhy = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-xhy'</span>);
cnchar.use(poly, order, trad, idiom, xhy);</code></pre></div> <h2 id="_2-cdn"><a href="#_2-cdn" class="header-anchor">#</a> 2. CDN</h2> <p>使 script 使</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar/cnchar.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span> <span class="hljs-keyword">var</span> radical = <span class="hljs-built_in">require</span>(<span class="hljs-string">'cnchar-radical'</span>);
cnchar.use(poly, order, trad, idiom, xhy, radical);</code></pre></div> <h2 id="_2-cdn"><a href="#_2-cdn" class="header-anchor">#</a> 2. CDN</h2> <p>使 script 使</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar/cnchar.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-comment">&lt;!--以下功能库请按需使用--&gt;</span> <span class="hljs-comment">&lt;!--以下功能库请按需使用--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-poly/cnchar.poly.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-poly/cnchar.poly.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-order/cnchar.order.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-order/cnchar.order.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"</span>&gt;</span> <span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"</span>&gt;</span> <span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"</span>&gt;</span> <span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"</span>&gt;</span> <span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <h2 id="_3-cnchar-all"><a href="#_3-cnchar-all" class="header-anchor">#</a> 3. cnchar-all</h2> <p>使cnchar<code>cnchar-all</code>使</p> <div><pre><code class="hljs">npm i cnchar-all</code></pre></div> <p>commonjs </p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-all'</span>;</code></pre></div> <p>cdn</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-all/cnchar.all.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <h2 id="_4-使"><a href="#_4-使" class="header-anchor">#</a> 4. 使</h2> <p>cnchar <code>spell</code> <code>stroke</code></p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>spell/stroke</span> <span class="code-desc" data-v-0175ad70></span> <i title="线" class="ei-play code-btn" data-v-0175ad70></i> <i title="" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70></div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70></span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70> <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"</span>&gt;</span> <span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <h2 id="_3-cnchar-all"><a href="#_3-cnchar-all" class="header-anchor">#</a> 3. cnchar-all</h2> <p>使cnchar<code>cnchar-all</code>使</p> <div><pre><code class="hljs">npm i cnchar-all</code></pre></div> <p>commonjs </p> <div><pre><code class="hljs javascript"><span class="hljs-keyword">import</span> cnchar <span class="hljs-keyword">from</span> <span class="hljs-string">'cnchar-all'</span>;</code></pre></div> <p>cdn</p> <div><pre><code class="hljs html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://cdn.jsdelivr.net/npm/cnchar-all/cnchar.all.min.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></code></pre></div> <h2 id="_4-使"><a href="#_4-使" class="header-anchor">#</a> 4. 使</h2> <p>cnchar <code>spell</code> <code>stroke</code></p> <div><div class="code-box" data-v-0175ad70><div data-v-0175ad70><span class="code-title" data-v-0175ad70>spell/stroke</span> <span class="code-desc" data-v-0175ad70></span> <i title="线" class="ei-play code-btn" data-v-0175ad70></i> <i title="" class="ei-copy code-btn" data-v-0175ad70></i></div> <pre data-v-0175ad70><code class="hljs"></code></pre> <div style="display:none;" data-v-0175ad70><div class="output-title" data-v-0175ad70></div> <div class="output-area" data-v-0175ad70><div class="show-toggle" data-v-0175ad70><i class="ei-angle-up" data-v-0175ad70></i> <span class="show-text" data-v-0175ad70></span></div> <div style="display:;" data-v-0175ad70></div></div></div> <div class="powered-by" data-v-0175ad70>
Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <p>使 <a href="/cnchar/v2/doc/cnchar">cnchar</a> </p></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">:</span> <span class="time">6/4/2020, 2:06:00 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev"> Powered by <a target="view_window" href="https://github.com/theajack/jsbox" class="jsbox-link" data-v-0175ad70><i class="ei-cube-alt" data-v-0175ad70></i> JSBox</a></div></div></div> <p>使 <a href="/cnchar/v2/doc/cnchar">cnchar</a> </p></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">:</span> <span class="time">6/4/2020, 2:06:00 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
@ -106,6 +114,6 @@ cnchar.use(poly, order, trad, idiom, xhy);</code></pre></div> <h2 id="_2-cdn引
</a> </a>
</span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div> </span></p></div> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.b0052b42.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/18.56e78ae6.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script> <script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/19.f46096eb.js" defer></script><script src="/cnchar/v2/assets/js/3.21c3e3be.js" defer></script>
</body> </body>
</html> </html>

File diff suppressed because one or more lines are too long

View File

@ -8,7 +8,7 @@
<meta name="generator" content="VuePress 1.4.0"> <meta name="generator" content="VuePress 1.4.0">
<link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico"> <link rel="icon" href="https://cdn.jsdelivr.net/gh/theajack/cnchar/docs/assets/v1/images/i.ico">
<link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.b0052b42.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/8.c52e8de4.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/4.fcf3f00c.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.6fe8a37b.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.afec1f15.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.d168a5e4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.0ea02f06.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4dd87a78.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.ad93db03.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.b4b4c0f9.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.56e78ae6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.43f4edea.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.1bd42485.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.45301e81.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.fdca0c28.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.c736cefc.js"><link rel="prefetch" href="/cnchar/v2/assets/js/3.21c3e3be.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.39b1109a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.7bf56da2.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.a1c7f0bf.js"> <link rel="preload" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css" as="style"><link rel="preload" href="/cnchar/v2/assets/js/app.1ef4e9a2.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/2.02fcc548.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/8.fe6aa719.js" as="script"><link rel="preload" href="/cnchar/v2/assets/js/4.828d46cb.js" as="script"><link rel="prefetch" href="/cnchar/v2/assets/js/10.35940bd6.js"><link rel="prefetch" href="/cnchar/v2/assets/js/11.5f7eeac4.js"><link rel="prefetch" href="/cnchar/v2/assets/js/12.077923da.js"><link rel="prefetch" href="/cnchar/v2/assets/js/13.356e982d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/14.793898e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/15.4b7779c5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/16.7f808694.js"><link rel="prefetch" href="/cnchar/v2/assets/js/17.a5cba3ff.js"><link rel="prefetch" href="/cnchar/v2/assets/js/18.91861afe.js"><link rel="prefetch" href="/cnchar/v2/assets/js/19.f46096eb.js"><link rel="prefetch" href="/cnchar/v2/assets/js/20.490147a5.js"><link rel="prefetch" href="/cnchar/v2/assets/js/21.e07d886f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/22.16178b4d.js"><link rel="prefetch" href="/cnchar/v2/assets/js/23.7bc08b9f.js"><link rel="prefetch" href="/cnchar/v2/assets/js/24.213eeff8.js"><link rel="prefetch" href="/cnchar/v2/assets/js/3.21c3e3be.js"><link rel="prefetch" href="/cnchar/v2/assets/js/5.207091e3.js"><link rel="prefetch" href="/cnchar/v2/assets/js/6.dfd0aa9a.js"><link rel="prefetch" href="/cnchar/v2/assets/js/7.1a244848.js"><link rel="prefetch" href="/cnchar/v2/assets/js/9.18ff6ea2.js">
<link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css"> <link rel="stylesheet" href="/cnchar/v2/assets/css/0.styles.f8ccd877.css">
</head> </head>
<body> <body>
@ -32,6 +32,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -60,6 +62,8 @@
cnchar-idiom: 成语 cnchar-idiom: 成语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/xhy.html" class="nav-link">
cnchar-xhy: 歇后语 cnchar-xhy: 歇后语
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/radical.html" class="nav-link">
cnchar-radical: 偏旁部首
</a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link"> </a></li><li class="dropdown-item"><!----> <a href="/cnchar/v2/doc/tool.html" class="nav-link">
工具方法 工具方法
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external"> </a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="" class="dropdown-title"><span class="title"></span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.github.com/theajack" target="_blank" rel="noopener noreferrer" class="nav-link external">
@ -69,7 +73,7 @@
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external"> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/yanxiaomu" target="_blank" rel="noopener noreferrer" class="nav-link external">
CSDN账号 CSDN账号
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <!----> </aside> <main class="page"> <div class="theme-default-content content__default"><div><div class="home-wrapper"><div><img src="/cnchar/v2/assets/img/logo.6cd28633.png" alt srcset class="logo"></div> <div class="title">cnchar</div> <div class="desc">js</div> <div class="test"><div class="test-input el-input"><!----><input type="text" autocomplete="off" placeholder="" class="el-input__inner"><!----><!----><!----><!----></div> <div class="show-area" style="display:none;"><div> <span class="split">|</span> </div> <div>: <span class="split">|</span> : </div> <div>: </div> <div id="draw-area"></div></div></div> <div class="start-w"><button type="button" class="el-button el-button--primary"><!----><!----><span> <i class="ei-location-arrow"></i></span></button></div> <div class="feature-w"><div class="f-i"><div class="f-t"><i class="ei-rocket"></i></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des">...</div></div> <div class="f-i"><div class="f-t"><i class="ei-tablet"></i></div> <div class="f-des"></div> <div class="f-des">nodejs</div> <div class="f-des">/</div> <div class="f-des">ReactNative/Weex/Uniapp/Electron</div> <div class="f-des">webpack</div> <div class="f-des">typescript</div> <div class="f-des">...</div></div> <div class="f-i"><div class="f-t"><i class="ei-cubes"></i></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des">npm</div> <div class="f-des">cdn</div></div></div> <div class="copy-right">MIT Licensed | Copyright © 2020 present <a href="https://www.github.com/theajack" target="view_window">theajack</a></div></div></div></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">:</span> <span class="time">4/14/2020, 1:02:43 AM</span></div></footer> <!----> </main></div><div class="global-ui"><!----><div></div></div></div> <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav> <!----> </aside> <main class="page"> <div class="theme-default-content content__default"><div><div class="home-wrapper"><div><img src="/cnchar/v2/assets/img/logo.6cd28633.png" alt srcset class="logo"></div> <div class="title">cnchar</div> <div class="desc">js</div> <div class="test"><div class="test-input el-input"><!----><input type="text" autocomplete="off" placeholder="" class="el-input__inner"><!----><!----><!----><!----></div> <div class="show-area" style="display:none;"><div> <span class="split">|</span> </div> <div>: <span class="split">|</span> : </div> <div>: </div> <div id="draw-area"></div></div></div> <div class="start-w"><button type="button" class="el-button el-button--primary"><!----><!----><span> <i class="ei-location-arrow"></i></span></button></div> <div class="feature-w"><div class="f-i"><div class="f-t"><i class="ei-rocket"></i></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des">...</div></div> <div class="f-i"><div class="f-t"><i class="ei-tablet"></i></div> <div class="f-des"></div> <div class="f-des">nodejs</div> <div class="f-des">/</div> <div class="f-des">ReactNative/Weex/Uniapp/Electron</div> <div class="f-des">webpack</div> <div class="f-des">typescript</div> <div class="f-des">...</div></div> <div class="f-i"><div class="f-t"><i class="ei-cubes"></i></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des"></div> <div class="f-des">npm</div> <div class="f-des">cdn</div></div></div> <div class="copy-right">MIT Licensed | Copyright © 2020 present <a href="https://www.github.com/theajack" target="view_window">theajack</a></div></div></div></div> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">:</span> <span class="time">4/14/2020, 1:02:43 AM</span></div></footer> <!----> </main></div><div class="global-ui"><!----><div></div></div></div>
<script src="/cnchar/v2/assets/js/app.b0052b42.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/8.c52e8de4.js" defer></script><script src="/cnchar/v2/assets/js/4.fcf3f00c.js" defer></script> <script src="/cnchar/v2/assets/js/app.1ef4e9a2.js" defer></script><script src="/cnchar/v2/assets/js/2.02fcc548.js" defer></script><script src="/cnchar/v2/assets/js/8.fe6aa719.js" defer></script><script src="/cnchar/v2/assets/js/4.828d46cb.js" defer></script>
<script> <script>
var _mtac = {}; var _mtac = {};
(function () { (function () {

View File

@ -90,10 +90,11 @@ Use the script tag to use:
13. Support **Idiom** query function, you can query idioms according to Chinese characters, pinyin (tone), stroke number 13. Support **Idiom** query function, you can query idioms according to Chinese characters, pinyin (tone), stroke number
14. Support **Xiehouyu** query function, support fuzzy query 14. Support **Xiehouyu** query function, support fuzzy query
15. Provide Chinese character tool method, which is convenient for developers to **operate pinyin and Chinese characters** 15. Provide Chinese character tool method, which is convenient for developers to **operate pinyin and Chinese characters**
16. **Small size**, min version is only 46 kb, zip version is 34 kb(contains a large number of Chinese Pinyin dictionaries) 16. Support **Range radicals** query function
17. **Multi-end available**, can be used in**browser, nodejs, applet / mini-game, ReactNative / Weex / Uniapp / Electron, webpack**..., supports all environments where js can run 17. **Small size**, min version is only 46 kb, zip version is 34 kb(contains a large number of Chinese Pinyin dictionaries)
18. **typescript support**, support calling in typescript 18. **Multi-end available**, can be used in**browser, nodejs, applet / mini-game, ReactNative / Weex / Uniapp / Electron, webpack**..., supports all environments where js can run
19. Rich configuration, split into 7 libraries according to function 19. **typescript support**, support calling in typescript
20. Rich configuration, split into 7 libraries according to function
### 2. Overview ### 2. Overview
@ -108,6 +109,7 @@ cnchar|The main js library, the other three libraries depend on this library|Con
| cnchar-draw|Drawing stroke library|Point out the visual drawing of Chinese characters, there are four modes of normal, animation, stroke, test optional, the library is only available in the browser environment | 2.1+ | | cnchar-draw|Drawing stroke library|Point out the visual drawing of Chinese characters, there are four modes of normal, animation, stroke, test optional, the library is only available in the browser environment | 2.1+ |
| cnchar-idiom | idiom library | support idiom query and other functions | 2.2+ | | cnchar-idiom | idiom library | support idiom query and other functions | 2.2+ |
| cnchar-xhy | Xiehou language library | Support Xiehouyu query and other functions | 2.2+ | | cnchar-xhy | Xiehou language library | Support Xiehouyu query and other functions | 2.2+ |
| cnchar-radical | Radical radical library | Support querying radicals of Chinese characters | 2.2.5+ |
### 3. Installation ### 3. Installation
@ -122,12 +124,12 @@ npm i cnchar
Install additional function library: Install additional function library:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
Of course, you can also install a few of them on demand, but the basic library `cnchar` must be installed (draw, idiom, xhy three libraries can be used independently) Of course, you can also install a few of them on demand, but the basic library `cnchar` must be installed (draw, idiom, xhy, radical four libraries can be used independently)
Or you can use the full functionality by installing `cnchar-all`, this library references the above four libraries Or you can use the full functionality by installing `cnchar-all`, this library references all the above plugin libraries
``` ```
npm i cnchar-all npm i cnchar-all
@ -143,6 +145,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
Or use the following cdn, which contains the above seven libraries Or use the following cdn, which contains the above seven libraries
@ -167,6 +170,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// Please use the plug-in as needed // Please use the plug-in as needed
console.log('汉字'.spell()); // Called by prototype console.log('汉字'.spell()); // Called by prototype
@ -187,9 +191,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// Please use the plug-in as needed // Please use the plug-in as needed
// cnchar-draw cannot be used in a non-browser environment // cnchar-draw cannot be used in a non-browser environment
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // Called by prototype console.log('汉字'.spell()); // Called by prototype
console.log(cnchar.spell('汉字')); // cnchar api call console.log(cnchar.spell('汉字')); // cnchar api call
@ -209,6 +214,7 @@ The native browser environment requires the use of script tags to import js file
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
    console.log('汉字'.spell()); // Called by prototype     console.log('汉字'.spell()); // Called by prototype
    console.log(cnchar.spell('汉字')); // cnchar api call     console.log(cnchar.spell('汉字')); // cnchar api call
@ -493,6 +499,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
When using cdn references, the `CncharIdiom` object will be exposed upward in the window
#### 5.8 Xiehouyu function #### 5.8 Xiehouyu function
cnchar added the Xiehouyu function in 2.2.0. To enable this function, you need to install the `cnchar-xhy` function library, which can be run independently of the main cnchar library. cnchar added the Xiehouyu function in 2.2.0. To enable this function, you need to install the `cnchar-xhy` function library, which can be run independently of the main cnchar library.
@ -516,11 +524,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 Chinese Characters and Pinyin Tools When using cdn references, the `CncharXHY` object will be exposed upwards in the window
#### 5.9 Radical radical function
Cnchar added the radical radical function in 2.2.5. To enable this function, you need to install the `cnchar-radical` function library, which can run independently of the cnchar main library
Thanks to pr provided by `kewell-tsao`
The usage is as follows:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
See a specific example
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// Return array
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// The incoming array will return the array by default
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
When using cdn references, the `CncharRadical` object will be exposed upwards in the window
#### 5.10 Chinese Characters and Pinyin Tools
cnchar organizes and exposes some methods of operating pinyin and Chinese characters used inside the library, which is convenient for developers to operate pinyin and Chinese characters conveniently and efficiently cnchar organizes and exposes some methods of operating pinyin and Chinese characters used inside the library, which is convenient for developers to operate pinyin and Chinese characters conveniently and efficiently
##### 5.9.1 Query pinyin details: spellInfo ##### 5.10.1 Query pinyin details: spellInfo
The `spellInfo` method is used to query the detailed information of Pinyin, the usage is as follows: The `spellInfo` method is used to query the detailed information of Pinyin, the usage is as follows:
@ -554,7 +589,7 @@ cnchar.spellInfo.tones;
// Use * instead of n // Use * instead of n
``` ```
##### 5.9.2 Pinyin tone operation: transformTone ##### 5.10.2 Pinyin tone operation: transformTone
The `transformTone` method is used to convert toned pinyin to toneless pinyin, and the tone position and tone The `transformTone` method is used to convert toned pinyin to toneless pinyin, and the tone position and tone
@ -578,7 +613,7 @@ type is an optional parameter, indicating that the return value spell sets the c
The transformTone spell parameter supports the use of v instead of ü, and the use of numbers at the end to represent the tone, for example, `lv is equivalent to lü`shang4 is equivalent to shàng` The transformTone spell parameter supports the use of v instead of ü, and the use of numbers at the end to represent the tone, for example, `lv is equivalent to lü`shang4 is equivalent to shàng`
##### 5.9.3 Is it Chinese characters: isCnChar ##### 5.10.3 Is it Chinese characters: isCnChar
The `isCnChar` method is used to determine whether a character is a Chinese character The `isCnChar` method is used to determine whether a character is a Chinese character
@ -586,7 +621,7 @@ The `isCnChar` method is used to determine whether a character is a Chinese char
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 Compare Pinyin (Chinese character) size: compareSpell ##### 5.10.4 Compare Pinyin (Chinese character) size: compareSpell
`CompareSpell` method is used to compare the size of Pinyin or Chinese characters according to Pinyin `CompareSpell` method is used to compare the size of Pinyin or Chinese characters according to Pinyin
@ -607,7 +642,7 @@ cnchar.compareSpell('ao', 'ai') // Returns 'more' because o comes after i
cnchar.compareSpell('奥', 'ai') // Returns 'more' cnchar.compareSpell('奥', 'ai') // Returns 'more'
``` ```
##### 5.9.5 Compare the number of strokes of Chinese characters: compareStroke ##### 5.10.5 Compare the number of strokes of Chinese characters: compareStroke
The `compareStroke` method is used to compare the size of Chinese characters according to the number of strokes. It can be used to sort the first Chinese character strokes according to the name. For sorting, please refer to the `sortStroke` method The `compareStroke` method is used to compare the size of Chinese characters according to the number of strokes. It can be used to sort the first Chinese character strokes according to the name. For sorting, please refer to the `sortStroke` method
@ -627,7 +662,7 @@ cnchar.compareStroke(20, '好') // Returns 'more'
cnchar.compareStroke('一个', '好') // Returns 'less' cnchar.compareStroke('一个', '好') // Returns 'less'
``` ```
##### 5.9.6 Sort by pinyin: sortSpell ##### 5.10.6 Sort by pinyin: sortSpell
The `sortSpell` method is used to sort Chinese characters or Pinyin according to Pinyin, supports input arrays or strings, supports sorting by tone, and supports reverse order The `sortSpell` method is used to sort Chinese characters or Pinyin according to Pinyin, supports input arrays or strings, supports sorting by tone, and supports reverse order
@ -649,7 +684,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 Sort by number of strokes: sortStroke ##### 5.10.7 Sort by number of strokes: sortStroke
The `sortStroke` method is used to sort Chinese characters according to the number of strokes The `sortStroke` method is used to sort Chinese characters according to the number of strokes
@ -671,9 +706,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 Other APIs #### 5.11 Other APIs
##### 5.10.1 .use() ##### 5.11.1 .use()
The function of this API is to explicitly enable the three function libraries `poly`,`order`, and `trad` The function of this API is to explicitly enable the three function libraries `poly`,`order`, and `trad`
@ -702,9 +737,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
The type object user gets the currently available `spell`,` stroke`, `orderToWord`,` spellToWord`, `strokeToWord` parameter types: The type object user gets the currently available `spell`,` stroke`, `orderToWord`,` spellToWord`, `strokeToWord`, `idiom`, `xhy`, `radical` parameter types:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -712,6 +747,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg Maximum available values: `['array','low','up','first','poly','tone','simple']` spellArg Maximum available values: `['array','low','up','first','poly','tone','simple']`
@ -724,9 +762,17 @@ spellToWordArg Maximum available values: `['simple','trad','poly','alltone','arr
strokeToWordArg Maximum available values: `['simple','trad','array']` strokeToWordArg Maximum available values: `['simple','trad','array']`
idiomArg Maximum available values: `['char','stroke','spell','tone']`
xhyArg Maximum available values: `['fuzzy','answer','second']`
radicalArg Maximum available values: `['array']`
The above values are all json
Specific usage <a href="#user-content-6-spell-stroke-parameters"> Chapter 6 </a> Specific usage <a href="#user-content-6-spell-stroke-parameters"> Chapter 6 </a>
##### 5.10.3 .check ##### 5.11.3 .check
This value is a Boolean type, used to control whether to enable parameter verification, the default value is true This value is a Boolean type, used to control whether to enable parameter verification, the default value is true
@ -736,7 +782,7 @@ Parameter verification can check the incoming parameters of `spell` and` stroke`
cnchar.check = false; // Turn off parameter check cnchar.check = false; // Turn off parameter check
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
Get the current version: Get the current version:
@ -744,7 +790,7 @@ Get the current version:
var version = cnchar.version; // string type var version = cnchar.version; // string type
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
List of currently used function libraries, the most common case is `["order","trad","poly"]` List of currently used function libraries, the most common case is `["order","trad","poly"]`
@ -893,9 +939,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | Whether to output only the answer | No | - | The default is to output the entire sentence of the rest of the sentence | | answer | Whether to output only the answer | No | - | The default is to output the entire sentence of the rest of the sentence |
| second | Is the query based on the last sentence of Xiehouyu | No | - | - | | second | Is the query based on the last sentence of Xiehouyu | No | - | - |
#### 6.8 Usage Examples: #### 6.8 radical parameters
##### 6.8.0 Installation and use The parameter call is as follows, value indicates the Chinese character to be queried for the radical, which can be a string or an array
```js
cnchar.radical(value,arg1,arg2,...);
```
| Parameter | Function | Whether Default | Dependency Library | Remarks |
| :-----: | :----: | :------: | :---: | :---: |
| array | Whether to return an array | No | -- | When passed in as an array, the array is returned by default |
#### 6.9 Usage Examples:
##### 6.9.0 Installation and use
npm way npm way
@ -917,7 +975,7 @@ script tag reference
</script> </script>
``` ```
##### 6.8.1 cnchar basic library function ##### 6.9.1 cnchar basic library function
```js ```js
// spell function // spell function
@ -952,7 +1010,7 @@ Remarks:
4. Stroke method Non-Chinese characters will count as 0 4. Stroke method Non-Chinese characters will count as 0
5. Stroke method order mode Non-Chinese characters will return undefined 5. Stroke method order mode Non-Chinese characters will return undefined
##### 6.8.2 cnchar-poly library function ##### 6.9.2 cnchar-poly library function
This library is used to accurately identify polyphonic words and also supports other parameter functions in 6.3.1 This library is used to accurately identify polyphonic words and also supports other parameter functions in 6.3.1
@ -962,7 +1020,7 @@ This library is used to accurately identify polyphonic words and also supports o
'长大了'.spell('poly'); // returns'(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // returns'(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order library function ##### 6.9.3 cnchar-order library function
This library is used to query the stroke order and stroke name of Chinese characters. The return value is an array. This library is used to query the stroke order and stroke name of Chinese characters. The return value is an array.
@ -1018,11 +1076,11 @@ cnchar.orderToWord(['横','撇','捺'],'contain');
// Back to"丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..."// Omit the following // Back to"丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..."// Omit the following
``` ```
##### 6.8.4 cnchar-trad library function ##### 6.9.4 cnchar-trad library function
This library is used to support the conversion of traditional Chinese characters to Mars and provide traditional Chinese characters for basic functions such as pinyin This library is used to support the conversion of traditional Chinese characters to Mars and provide traditional Chinese characters for basic functions such as pinyin
###### 6.8.4.1 convert font conversion ###### 6.9.4.1 convert font conversion
```js ```js
'一个人'.convertSimpleToTrad(); // returns"壹個人"is equivalent to cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // returns"壹個人"is equivalent to cnchar.convert.simpleToTrad
@ -1044,7 +1102,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell and stroke methods ###### 6.9.4.2 spell and stroke methods
The library adds pinyin stroke function extension for traditional characters, and other basic usages are consistent with the basic library: The library adds pinyin stroke function extension for traditional characters, and other basic usages are consistent with the basic library:
@ -1060,7 +1118,7 @@ The library adds pinyin stroke function extension for traditional characters, an
'長大'.stroke('order','shape','simple'); // returns [undefined, ["㇐","","㇏"]] '長大'.stroke('order','shape','simple'); // returns [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom library function ##### 6.9.5 cnchar-idiom library function
This library extends the idiom function for cnchar This library extends the idiom function for cnchar
@ -1071,7 +1129,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy library function ##### 6.9.6 cnchar-xhy library function
This library extends the function of Xiehouyu for cnchar This library extends the function of Xiehouyu for cnchar
@ -1082,18 +1140,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 Tools and methods ##### 6.9.7 cnchar-radical library function
The library extends the radical function for cnchar
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 Tools and methods
cnchar provides some Chinese character tool methods to facilitate developers to operate pinyin and Chinese characters more conveniently and efficiently cnchar provides some Chinese character tool methods to facilitate developers to operate pinyin and Chinese characters more conveniently and efficiently
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// Returns {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // Returns {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1103,7 +1172,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1112,7 +1181,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1124,7 +1193,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1134,7 +1203,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1145,7 +1214,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

View File

@ -95,11 +95,12 @@ import cnchar from 'cnchar';
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
### 2.概览 ### 2.概览
@ -114,6 +115,7 @@ import cnchar from 'cnchar';
| cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ | | cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ |
| cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ | | cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ |
| cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| cnchar-radical | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
### 3.安装 ### 3.安装
@ -128,12 +130,12 @@ npm i cnchar
安装附加功能库: 安装附加功能库:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) 当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的四个 或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的所有插件
``` ```
npm i cnchar-all npm i cnchar-all
@ -148,6 +150,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
或使用以下cdn包含了以上七个库 或使用以下cdn包含了以上七个库
@ -171,6 +174,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// 插件请按需取用 // 插件请按需取用
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
@ -191,9 +195,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// 插件请按需取用 // 插件请按需取用
// 注cnchar-draw 在非浏览器环境下不可使用 // 注cnchar-draw 在非浏览器环境下不可使用
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -213,6 +218,7 @@ console.log(cnchar.spell('汉字')); // cnchar api 调用
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -498,6 +504,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
#### 5.8 歇后语功能 #### 5.8 歇后语功能
cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行 cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行
@ -521,11 +529,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 汉字、拼音工具方法 使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
#### 5.9 偏旁部首功能
cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
#### 5.10 汉字、拼音工具方法
cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字 cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字
##### 5.9.1 查询拼音详细信息: spellInfo ##### 5.10.1 查询拼音详细信息: spellInfo
`spellInfo` 方法用于查询拼音的详细信息,用法如下: `spellInfo` 方法用于查询拼音的详细信息,用法如下:
@ -559,7 +594,7 @@ cnchar.spellInfo.tones;
// n 的一声使用 * 代替 // n 的一声使用 * 代替
``` ```
##### 5.9.2 拼音音调操作: transformTone ##### 5.10.2 拼音音调操作: transformTone
`transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调 `transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调
@ -583,7 +618,7 @@ type 为可选参数表示返回值spell设置大小写默认为 'low'
transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng` transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng`
##### 5.9.3 是否是汉字: isCnChar ##### 5.10.3 是否是汉字: isCnChar
`isCnChar` 方法用于判断一个字符是否是汉字 `isCnChar` 方法用于判断一个字符是否是汉字
@ -591,7 +626,7 @@ transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 比较拼音(汉字)大小: compareSpell ##### 5.10.4 比较拼音(汉字)大小: compareSpell
`compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景 `compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景
@ -612,7 +647,7 @@ cnchar.compareSpell('ao', 'ai') // 返回 'more' 因为 o 排在 i 之后
cnchar.compareSpell('奥', 'ai') // 返回 'more' cnchar.compareSpell('奥', 'ai') // 返回 'more'
``` ```
##### 5.9.5 比较汉字笔画数大小: compareStroke ##### 5.10.5 比较汉字笔画数大小: compareStroke
`compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法 `compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法
@ -632,7 +667,7 @@ cnchar.compareStroke(20, '好') // 返回 'more'
cnchar.compareStroke('一个', '好') // 返回 'less' cnchar.compareStroke('一个', '好') // 返回 'less'
``` ```
##### 5.9.6 根据拼音排序: sortSpell ##### 5.10.6 根据拼音排序: sortSpell
`sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序 `sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序
@ -654,7 +689,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 根据笔画数排序: sortStroke ##### 5.10.7 根据笔画数排序: sortStroke
`sortStroke` 方法用于按照笔画数排序汉字 `sortStroke` 方法用于按照笔画数排序汉字
@ -676,9 +711,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 其他 api #### 5.11 其他 api
##### 5.10.1 .use() ##### 5.11.1 .use()
这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库 这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库
@ -707,9 +742,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord` 参数类型: type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord`、`idiom`、 `xhy`、`radical` 参数类型:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -717,6 +752,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']` spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']`
@ -729,9 +767,17 @@ spellToWordArg 最多可用值: `['simple','trad','poly','alltone','array']`
strokeToWordArg 最多可用值: `['simple','trad','array']` strokeToWordArg 最多可用值: `['simple','trad','array']`
idiomArg 最多可用值: `['char','stroke','spell','tone']`
xhyArg 最多可用值: `['fuzzy','answer','second']`
radicalArg 最多可用值: `['array']`
以上值皆为 json
具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到 具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到
##### 5.10.3 .check ##### 5.11.3 .check
该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true 该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true
@ -741,7 +787,7 @@ strokeToWordArg 最多可用值: `['simple','trad','array']`
cnchar.check = false; // 关闭参数校验 cnchar.check = false; // 关闭参数校验
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
获取当前版本: 获取当前版本:
@ -749,7 +795,7 @@ cnchar.check = false; // 关闭参数校验
var version = cnchar.version; // string 类型 var version = cnchar.version; // string 类型
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]` 当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]`
@ -898,9 +944,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 | | answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 |
| second | 是否是根据歇后语后一句查询 | 否 | -- | -- | | second | 是否是根据歇后语后一句查询 | 否 | -- | -- |
#### 6.8 使用实例大全: #### 6.8 radical 参数
##### 6.8.0 安装使用 参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
#### 6.9 使用实例大全:
##### 6.9.0 安装使用
npm 方式 npm 方式
@ -922,7 +980,7 @@ script 标签引用 方式
</script> </script>
``` ```
##### 6.8.1 cnchar 基础库功能 ##### 6.9.1 cnchar 基础库功能
```js ```js
//spell 功能 //spell 功能
@ -957,7 +1015,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
4. stroke 方法 非中文字符会笔画数会计为 0 4. stroke 方法 非中文字符会笔画数会计为 0
5. stroke 方法 order 模式 非中文字符会返回 undefined 5. stroke 方法 order 模式 非中文字符会返回 undefined
##### 6.8.2 cnchar-poly 库功能 ##### 6.9.2 cnchar-poly 库功能
该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能 该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能
@ -967,7 +1025,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
'长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order 库功能 ##### 6.9.3 cnchar-order 库功能
该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组 该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组
@ -1023,11 +1081,11 @@ cnchar.orderToWord(['横', '撇', '捺'], 'contain');
// 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的 // 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的
``` ```
##### 6.8.4 cnchar-trad 库功能 ##### 6.9.4 cnchar-trad 库功能
该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持 该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持
###### 6.8.4.1 convert 字体转换 ###### 6.9.4.1 convert 字体转换
```js ```js
'一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad
@ -1049,7 +1107,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell 和 stroke 方法 ###### 6.9.4.2 spell 和 stroke 方法
该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致: 该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致:
@ -1065,7 +1123,7 @@ cnchar.convert.sparkToTrad('①个亾');
'長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]] '長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom 库功能 ##### 6.9.5 cnchar-idiom 库功能
该库为cnchar扩展了成语功能 该库为cnchar扩展了成语功能
@ -1076,7 +1134,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy 库功能 ##### 6.9.6 cnchar-xhy 库功能
该库为cnchar扩展了歇后语功能 该库为cnchar扩展了歇后语功能
@ -1087,18 +1145,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 工具方法 ##### 6.9.7 cnchar-radical 库功能
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 工具方法
cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字 cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1108,7 +1177,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1117,7 +1186,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1129,7 +1198,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1139,7 +1208,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1150,7 +1219,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

View File

@ -11,6 +11,7 @@ let files = [
'../npm/draw/package.json', '../npm/draw/package.json',
'../npm/idiom/package.json', '../npm/idiom/package.json',
'../npm/xhy/package.json', '../npm/xhy/package.json',
'../npm/radical/package.json',
'../npm/cnchar/package.json', '../npm/cnchar/package.json',
'../npm/all/package.json', '../npm/all/package.json',
'../npm/hanzi-util/package.json', '../npm/hanzi-util/package.json',
@ -65,6 +66,7 @@ function copyToNPM () {
.pipe(gulp.dest('npm/trad')) .pipe(gulp.dest('npm/trad'))
.pipe(gulp.dest('npm/draw')) .pipe(gulp.dest('npm/draw'))
.pipe(gulp.dest('npm/idiom')) .pipe(gulp.dest('npm/idiom'))
.pipe(gulp.dest('npm/radical'))
.pipe(gulp.dest('npm/xhy')); .pipe(gulp.dest('npm/xhy'));
gulp.src(['src/main/*.json', 'src/main/*.d.ts', 'LICENSE']) gulp.src(['src/main/*.json', 'src/main/*.d.ts', 'LICENSE'])
@ -85,6 +87,9 @@ function copyToNPM () {
gulp.src(['src/plugin/idiom/*.json', 'src/plugin/idiom/*.d.ts', 'LICENSE']) gulp.src(['src/plugin/idiom/*.json', 'src/plugin/idiom/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/idiom')); .pipe(gulp.dest('npm/idiom'));
gulp.src(['src/plugin/radical/*.json', 'src/plugin/radical/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/radical'));
gulp.src(['src/plugin/xhy/*.json', 'src/plugin/xhy/*.d.ts', 'LICENSE']) gulp.src(['src/plugin/xhy/*.json', 'src/plugin/xhy/*.d.ts', 'LICENSE'])
.pipe(gulp.dest('npm/xhy')); .pipe(gulp.dest('npm/xhy'));
@ -152,6 +157,10 @@ function transEs6ByBabel () {
.pipe(babel({presets: ['@babel/env']})) .pipe(babel({presets: ['@babel/env']}))
.pipe(gulp.dest('npm/xhy')); .pipe(gulp.dest('npm/xhy'));
gulp.src('src/plugin/radical/*.js')
.pipe(babel({presets: ['@babel/env']}))
.pipe(gulp.dest('npm/radical'));
gulp.src('src/plugin/all/*.js') gulp.src('src/plugin/all/*.js')
.pipe(babel({presets: ['@babel/env']})) .pipe(babel({presets: ['@babel/env']}))
.pipe(gulp.dest('npm/all')); .pipe(gulp.dest('npm/all'));

View File

@ -103,3 +103,6 @@
## 2.2.4 ## 2.2.4
1. 增加 红 字的默认读音 1. 增加 红 字的默认读音
## 2.2.5
1. 增加cnchar-radical, 偏旁部首插件库

File diff suppressed because one or more lines are too long

View File

@ -14,5 +14,7 @@ var idiom = require('../idiom');
var xhy = require('../xhy'); var xhy = require('../xhy');
cnchar.use(order, trad, poly, draw, idiom, xhy); var radical = require('../radical');
cnchar.use(order, trad, poly, draw, idiom, xhy, radical);
module.exports = cnchar; module.exports = cnchar;

View File

@ -1,6 +1,6 @@
{ {
"name": "cnchar-all", "name": "cnchar-all",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"unpkg": "cnchar.all.min.js", "unpkg": "cnchar.all.min.js",
@ -27,12 +27,12 @@
}, },
"homepage": "https://www.theajack.com/cnchar/", "homepage": "https://www.theajack.com/cnchar/",
"dependencies": { "dependencies": {
"cnchar": "^2.2.4", "cnchar": "^2.2.5",
"cnchar-order": "^2.2.4", "cnchar-order": "^2.2.5",
"cnchar-poly": "^2.2.4", "cnchar-poly": "^2.2.5",
"cnchar-trad": "^2.2.4", "cnchar-trad": "^2.2.5",
"cnchar-draw": "^2.2.4", "cnchar-draw": "^2.2.5",
"cnchar-idiom": "^2.2.4", "cnchar-idiom": "^2.2.5",
"cnchar-xhy": "^2.2.4" "cnchar-xhy": "^2.2.5"
} }
} }

View File

@ -54,20 +54,21 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword) * [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword)
* [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.9 汉字、拼音工具方法](#59-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) * [5.9 偏旁部首功能](#59-%E5%81%8F%E6%97%81%E9%83%A8%E9%A6%96%E5%8A%9F%E8%83%BD)
+ [5.9.1 查询拼音详细信息: spellInfo](#591-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo) * [5.10 汉字、拼音工具方法](#510-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
+ [5.9.2 拼音音调操作: transformTone](#592-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone) + [5.10.1 查询拼音详细信息: spellInfo](#5101-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo)
+ [5.9.3 是否是汉字: isCnChar](#593-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar) + [5.10.2 拼音音调操作: transformTone](#5102-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone)
+ [5.9.4 比较拼音(汉字)大小: compareSpell](#594-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell) + [5.10.3 是否是汉字: isCnChar](#5103-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar)
+ [5.9.5 比较汉字笔画数大小: compareStroke](#595-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke) + [5.10.4 比较拼音(汉字)大小: compareSpell](#5104-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell)
+ [5.9.6 根据拼音排序: sortSpell](#596-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell) + [5.10.5 比较汉字笔画数大小: compareStroke](#5105-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke)
+ [5.9.7 根据笔画数排序: sortStroke](#597-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke) + [5.10.6 根据拼音排序: sortSpell](#5106-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell)
* [5.10 其他 api](#510-%E5%85%B6%E4%BB%96-api) + [5.10.7 根据笔画数排序: sortStroke](#5107-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke)
+ [5.10.1 .use()](#5101-use) * [5.11 其他 api](#511-%E5%85%B6%E4%BB%96-api)
+ [5.10.2 .type](#5102-type) + [5.11.1 .use()](#5111-use)
+ [5.10.3 .check](#5103-check) + [5.11.2 .type](#5112-type)
+ [5.10.4 .version](#5104-version) + [5.11.3 .check](#5113-check)
+ [5.10.5 .plugins](#5105-plugins) + [5.11.4 .version](#5114-version)
+ [5.11.5 .plugins](#5115-plugins)
- [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0) - [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0)
* [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0) * [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0)
* [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0) * [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0)
@ -76,24 +77,26 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0) * [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0)
* [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0) * [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0)
* [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0) * [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0)
* [6.8 使用实例大全:](#68-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8) * [6.8 radical 参数](#68-radical-%E5%8F%82%E6%95%B0)
+ [6.8.0 安装使用](#680-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8) * [6.9 使用实例大全:](#69-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8)
+ [6.8.1 cnchar 基础库功能](#681-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.0 安装使用](#690-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8)
+ [6.8.2 cnchar-poly 库功能](#682-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.1 cnchar 基础库功能](#691-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.3 cnchar-order 库功能](#683-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.2 cnchar-poly 库功能](#692-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.4 cnchar-trad 库功能](#684-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.3 cnchar-order 库功能](#693-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.1 convert 字体转换](#6841-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2) + [6.9.4 cnchar-trad 库功能](#694-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.2 spell 和 stroke 方法](#6842-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95) - [6.9.4.1 convert 字体转换](#6941-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2)
+ [6.8.5 cnchar-idiom 库功能](#685-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD) - [6.9.4.2 spell 和 stroke 方法](#6942-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95)
+ [6.8.6 cnchar-xhy 库功能](#686-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.5 cnchar-idiom 库功能](#695-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.7 工具方法](#687-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) + [6.9.6 cnchar-xhy 库功能](#696-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.1 spellInfo](#6871-spellinfo) + [6.9.7 cnchar-radical 库功能](#697-cnchar-radical-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.2 isCnChar](#6872-iscnchar) + [6.9.8 工具方法](#698-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
- [6.8.7.3 transformTone](#6873-transformtone) - [6.9.8.1 spellInfo](#6981-spellinfo)
- [6.8.7.4 compareSpell](#6874-comparespell) - [6.9.8.2 isCnChar](#6982-iscnchar)
- [6.8.7.5 compareStroke](#6875-comparestroke) - [6.9.8.3 transformTone](#6983-transformtone)
- [6.8.7.6 sortSpell](#6876-sortspell) - [6.9.8.4 compareSpell](#6984-comparespell)
- [6.8.7.7 sortStroke](#6877-sortstroke) - [6.9.8.5 compareStroke](#6985-comparestroke)
- [6.9.8.6 sortSpell](#6986-sortspell)
- [6.9.8.7 sortStroke](#6987-sortstroke)
- [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90) - [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90)
<!-- tocstop --> <!-- tocstop -->
@ -162,11 +165,12 @@ import cnchar from 'cnchar';
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
### 2.概览 ### 2.概览
@ -181,6 +185,7 @@ import cnchar from 'cnchar';
| cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ | | cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ |
| cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ | | cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ |
| cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| cnchar-radical | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
### 3.安装 ### 3.安装
@ -195,12 +200,12 @@ npm i cnchar
安装附加功能库: 安装附加功能库:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) 当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的四个 或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的所有插件
``` ```
npm i cnchar-all npm i cnchar-all
@ -215,6 +220,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
或使用以下cdn包含了以上七个库 或使用以下cdn包含了以上七个库
@ -238,6 +244,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// 插件请按需取用 // 插件请按需取用
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
@ -258,9 +265,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// 插件请按需取用 // 插件请按需取用
// 注cnchar-draw 在非浏览器环境下不可使用 // 注cnchar-draw 在非浏览器环境下不可使用
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -280,6 +288,7 @@ console.log(cnchar.spell('汉字')); // cnchar api 调用
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -565,6 +574,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
#### 5.8 歇后语功能 #### 5.8 歇后语功能
cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行 cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行
@ -588,11 +599,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 汉字、拼音工具方法 使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
#### 5.9 偏旁部首功能
cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
#### 5.10 汉字、拼音工具方法
cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字 cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字
##### 5.9.1 查询拼音详细信息: spellInfo ##### 5.10.1 查询拼音详细信息: spellInfo
`spellInfo` 方法用于查询拼音的详细信息,用法如下: `spellInfo` 方法用于查询拼音的详细信息,用法如下:
@ -626,7 +664,7 @@ cnchar.spellInfo.tones;
// n 的一声使用 * 代替 // n 的一声使用 * 代替
``` ```
##### 5.9.2 拼音音调操作: transformTone ##### 5.10.2 拼音音调操作: transformTone
`transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调 `transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调
@ -650,7 +688,7 @@ type 为可选参数表示返回值spell设置大小写默认为 'low'
transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng` transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng`
##### 5.9.3 是否是汉字: isCnChar ##### 5.10.3 是否是汉字: isCnChar
`isCnChar` 方法用于判断一个字符是否是汉字 `isCnChar` 方法用于判断一个字符是否是汉字
@ -658,7 +696,7 @@ transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 比较拼音(汉字)大小: compareSpell ##### 5.10.4 比较拼音(汉字)大小: compareSpell
`compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景 `compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景
@ -679,7 +717,7 @@ cnchar.compareSpell('ao', 'ai') // 返回 'more' 因为 o 排在 i 之后
cnchar.compareSpell('奥', 'ai') // 返回 'more' cnchar.compareSpell('奥', 'ai') // 返回 'more'
``` ```
##### 5.9.5 比较汉字笔画数大小: compareStroke ##### 5.10.5 比较汉字笔画数大小: compareStroke
`compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法 `compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法
@ -699,7 +737,7 @@ cnchar.compareStroke(20, '好') // 返回 'more'
cnchar.compareStroke('一个', '好') // 返回 'less' cnchar.compareStroke('一个', '好') // 返回 'less'
``` ```
##### 5.9.6 根据拼音排序: sortSpell ##### 5.10.6 根据拼音排序: sortSpell
`sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序 `sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序
@ -721,7 +759,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 根据笔画数排序: sortStroke ##### 5.10.7 根据笔画数排序: sortStroke
`sortStroke` 方法用于按照笔画数排序汉字 `sortStroke` 方法用于按照笔画数排序汉字
@ -743,9 +781,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 其他 api #### 5.11 其他 api
##### 5.10.1 .use() ##### 5.11.1 .use()
这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库 这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库
@ -774,9 +812,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord` 参数类型: type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord`、`idiom`、 `xhy`、`radical` 参数类型:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -784,6 +822,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']` spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']`
@ -796,9 +837,17 @@ spellToWordArg 最多可用值: `['simple','trad','poly','alltone','array']`
strokeToWordArg 最多可用值: `['simple','trad','array']` strokeToWordArg 最多可用值: `['simple','trad','array']`
idiomArg 最多可用值: `['char','stroke','spell','tone']`
xhyArg 最多可用值: `['fuzzy','answer','second']`
radicalArg 最多可用值: `['array']`
以上值皆为 json
具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到 具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到
##### 5.10.3 .check ##### 5.11.3 .check
该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true 该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true
@ -808,7 +857,7 @@ strokeToWordArg 最多可用值: `['simple','trad','array']`
cnchar.check = false; // 关闭参数校验 cnchar.check = false; // 关闭参数校验
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
获取当前版本: 获取当前版本:
@ -816,7 +865,7 @@ cnchar.check = false; // 关闭参数校验
var version = cnchar.version; // string 类型 var version = cnchar.version; // string 类型
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]` 当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]`
@ -965,9 +1014,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 | | answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 |
| second | 是否是根据歇后语后一句查询 | 否 | -- | -- | | second | 是否是根据歇后语后一句查询 | 否 | -- | -- |
#### 6.8 使用实例大全: #### 6.8 radical 参数
##### 6.8.0 安装使用 参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
#### 6.9 使用实例大全:
##### 6.9.0 安装使用
npm 方式 npm 方式
@ -989,7 +1050,7 @@ script 标签引用 方式
</script> </script>
``` ```
##### 6.8.1 cnchar 基础库功能 ##### 6.9.1 cnchar 基础库功能
```js ```js
//spell 功能 //spell 功能
@ -1024,7 +1085,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
4. stroke 方法 非中文字符会笔画数会计为 0 4. stroke 方法 非中文字符会笔画数会计为 0
5. stroke 方法 order 模式 非中文字符会返回 undefined 5. stroke 方法 order 模式 非中文字符会返回 undefined
##### 6.8.2 cnchar-poly 库功能 ##### 6.9.2 cnchar-poly 库功能
该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能 该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能
@ -1034,7 +1095,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
'长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order 库功能 ##### 6.9.3 cnchar-order 库功能
该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组 该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组
@ -1090,11 +1151,11 @@ cnchar.orderToWord(['横', '撇', '捺'], 'contain');
// 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的 // 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的
``` ```
##### 6.8.4 cnchar-trad 库功能 ##### 6.9.4 cnchar-trad 库功能
该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持 该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持
###### 6.8.4.1 convert 字体转换 ###### 6.9.4.1 convert 字体转换
```js ```js
'一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad
@ -1116,7 +1177,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell 和 stroke 方法 ###### 6.9.4.2 spell 和 stroke 方法
该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致: 该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致:
@ -1132,7 +1193,7 @@ cnchar.convert.sparkToTrad('①个亾');
'長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]] '長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom 库功能 ##### 6.9.5 cnchar-idiom 库功能
该库为cnchar扩展了成语功能 该库为cnchar扩展了成语功能
@ -1143,7 +1204,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy 库功能 ##### 6.9.6 cnchar-xhy 库功能
该库为cnchar扩展了歇后语功能 该库为cnchar扩展了歇后语功能
@ -1154,18 +1215,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 工具方法 ##### 6.9.7 cnchar-radical 库功能
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 工具方法
cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字 cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1175,7 +1247,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1184,7 +1256,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1196,7 +1268,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1206,7 +1278,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1217,7 +1289,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ declare type spellArg = 'array' | 'low' | 'up' | 'first' | 'poly' | 'tone' | 'si
declare type strokeArg = 'letter' | 'shape' | 'count' | 'name' | 'detail' | 'array' | 'order' | 'simple' | 'trad'; declare type strokeArg = 'letter' | 'shape' | 'count' | 'name' | 'detail' | 'array' | 'order' | 'simple' | 'trad';
declare type spellToWordArg = 'poly' | 'alltone' | 'array' | 'simple' | 'trad'; declare type spellToWordArg = 'poly' | 'alltone' | 'array' | 'simple' | 'trad';
declare type strokeToWordArg = 'array' | 'simple' | 'trad'; declare type strokeToWordArg = 'array' | 'simple' | 'trad';
declare type pluginArg = 'order' | 'trad' | 'poly' | 'draw' | 'idiom' | 'xhy'; declare type pluginArg = 'order' | 'trad' | 'poly' | 'draw' | 'idiom' | 'xhy' | 'radical';
declare type toneType = 0 | 1 | 2 | 3 | 4; declare type toneType = 0 | 1 | 2 | 3 | 4;
declare type compareType = 'more' | 'less' | 'even'; declare type compareType = 'more' | 'less' | 'even';
@ -35,6 +35,7 @@ export declare interface CnCharStatic {
orderToWord?: object; orderToWord?: object;
idiom?: object; idiom?: object;
xhy?: object; xhy?: object;
radical?: object;
}; };
check: boolean; check: boolean;
readonly version: string; readonly version: string;

View File

@ -1,6 +1,6 @@
{ {
"name": "cnchar", "name": "cnchar",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"scripts": {}, "scripts": {},

View File

@ -374,7 +374,7 @@ function checkArgs(type, args, jumpNext) {
} else { } else {
check(['tone']); check(['tone']);
} }
} else if (type === 'xhy') {} } else if (type === 'xhy') {} else if (type === 'radical') {}
warnArgs(useless, '无效', type); warnArgs(useless, '无效', type);
warnArgs(ignore, '被忽略', type); warnArgs(ignore, '被忽略', type);

View File

@ -1,3 +1,3 @@
"use strict"; "use strict";
module.exports = '2.2.4'; module.exports = '2.2.5';

View File

@ -54,20 +54,21 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword) * [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword)
* [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.9 汉字、拼音工具方法](#59-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) * [5.9 偏旁部首功能](#59-%E5%81%8F%E6%97%81%E9%83%A8%E9%A6%96%E5%8A%9F%E8%83%BD)
+ [5.9.1 查询拼音详细信息: spellInfo](#591-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo) * [5.10 汉字、拼音工具方法](#510-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
+ [5.9.2 拼音音调操作: transformTone](#592-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone) + [5.10.1 查询拼音详细信息: spellInfo](#5101-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo)
+ [5.9.3 是否是汉字: isCnChar](#593-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar) + [5.10.2 拼音音调操作: transformTone](#5102-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone)
+ [5.9.4 比较拼音(汉字)大小: compareSpell](#594-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell) + [5.10.3 是否是汉字: isCnChar](#5103-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar)
+ [5.9.5 比较汉字笔画数大小: compareStroke](#595-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke) + [5.10.4 比较拼音(汉字)大小: compareSpell](#5104-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell)
+ [5.9.6 根据拼音排序: sortSpell](#596-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell) + [5.10.5 比较汉字笔画数大小: compareStroke](#5105-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke)
+ [5.9.7 根据笔画数排序: sortStroke](#597-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke) + [5.10.6 根据拼音排序: sortSpell](#5106-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell)
* [5.10 其他 api](#510-%E5%85%B6%E4%BB%96-api) + [5.10.7 根据笔画数排序: sortStroke](#5107-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke)
+ [5.10.1 .use()](#5101-use) * [5.11 其他 api](#511-%E5%85%B6%E4%BB%96-api)
+ [5.10.2 .type](#5102-type) + [5.11.1 .use()](#5111-use)
+ [5.10.3 .check](#5103-check) + [5.11.2 .type](#5112-type)
+ [5.10.4 .version](#5104-version) + [5.11.3 .check](#5113-check)
+ [5.10.5 .plugins](#5105-plugins) + [5.11.4 .version](#5114-version)
+ [5.11.5 .plugins](#5115-plugins)
- [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0) - [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0)
* [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0) * [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0)
* [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0) * [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0)
@ -76,24 +77,26 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0) * [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0)
* [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0) * [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0)
* [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0) * [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0)
* [6.8 使用实例大全:](#68-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8) * [6.8 radical 参数](#68-radical-%E5%8F%82%E6%95%B0)
+ [6.8.0 安装使用](#680-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8) * [6.9 使用实例大全:](#69-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8)
+ [6.8.1 cnchar 基础库功能](#681-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.0 安装使用](#690-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8)
+ [6.8.2 cnchar-poly 库功能](#682-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.1 cnchar 基础库功能](#691-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.3 cnchar-order 库功能](#683-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.2 cnchar-poly 库功能](#692-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.4 cnchar-trad 库功能](#684-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.3 cnchar-order 库功能](#693-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.1 convert 字体转换](#6841-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2) + [6.9.4 cnchar-trad 库功能](#694-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.2 spell 和 stroke 方法](#6842-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95) - [6.9.4.1 convert 字体转换](#6941-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2)
+ [6.8.5 cnchar-idiom 库功能](#685-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD) - [6.9.4.2 spell 和 stroke 方法](#6942-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95)
+ [6.8.6 cnchar-xhy 库功能](#686-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.5 cnchar-idiom 库功能](#695-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.7 工具方法](#687-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) + [6.9.6 cnchar-xhy 库功能](#696-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.1 spellInfo](#6871-spellinfo) + [6.9.7 cnchar-radical 库功能](#697-cnchar-radical-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.2 isCnChar](#6872-iscnchar) + [6.9.8 工具方法](#698-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
- [6.8.7.3 transformTone](#6873-transformtone) - [6.9.8.1 spellInfo](#6981-spellinfo)
- [6.8.7.4 compareSpell](#6874-comparespell) - [6.9.8.2 isCnChar](#6982-iscnchar)
- [6.8.7.5 compareStroke](#6875-comparestroke) - [6.9.8.3 transformTone](#6983-transformtone)
- [6.8.7.6 sortSpell](#6876-sortspell) - [6.9.8.4 compareSpell](#6984-comparespell)
- [6.8.7.7 sortStroke](#6877-sortstroke) - [6.9.8.5 compareStroke](#6985-comparestroke)
- [6.9.8.6 sortSpell](#6986-sortspell)
- [6.9.8.7 sortStroke](#6987-sortstroke)
- [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90) - [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90)
<!-- tocstop --> <!-- tocstop -->
@ -162,11 +165,12 @@ import cnchar from 'cnchar';
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
### 2.概览 ### 2.概览
@ -181,6 +185,7 @@ import cnchar from 'cnchar';
| cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ | | cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ |
| cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ | | cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ |
| cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| cnchar-radical | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
### 3.安装 ### 3.安装
@ -195,12 +200,12 @@ npm i cnchar
安装附加功能库: 安装附加功能库:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) 当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的四个 或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的所有插件
``` ```
npm i cnchar-all npm i cnchar-all
@ -215,6 +220,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
或使用以下cdn包含了以上七个库 或使用以下cdn包含了以上七个库
@ -238,6 +244,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// 插件请按需取用 // 插件请按需取用
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
@ -258,9 +265,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// 插件请按需取用 // 插件请按需取用
// 注cnchar-draw 在非浏览器环境下不可使用 // 注cnchar-draw 在非浏览器环境下不可使用
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -280,6 +288,7 @@ console.log(cnchar.spell('汉字')); // cnchar api 调用
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -565,6 +574,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
#### 5.8 歇后语功能 #### 5.8 歇后语功能
cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行 cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行
@ -588,11 +599,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 汉字、拼音工具方法 使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
#### 5.9 偏旁部首功能
cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
#### 5.10 汉字、拼音工具方法
cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字 cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字
##### 5.9.1 查询拼音详细信息: spellInfo ##### 5.10.1 查询拼音详细信息: spellInfo
`spellInfo` 方法用于查询拼音的详细信息,用法如下: `spellInfo` 方法用于查询拼音的详细信息,用法如下:
@ -626,7 +664,7 @@ cnchar.spellInfo.tones;
// n 的一声使用 * 代替 // n 的一声使用 * 代替
``` ```
##### 5.9.2 拼音音调操作: transformTone ##### 5.10.2 拼音音调操作: transformTone
`transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调 `transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调
@ -650,7 +688,7 @@ type 为可选参数表示返回值spell设置大小写默认为 'low'
transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng` transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng`
##### 5.9.3 是否是汉字: isCnChar ##### 5.10.3 是否是汉字: isCnChar
`isCnChar` 方法用于判断一个字符是否是汉字 `isCnChar` 方法用于判断一个字符是否是汉字
@ -658,7 +696,7 @@ transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 比较拼音(汉字)大小: compareSpell ##### 5.10.4 比较拼音(汉字)大小: compareSpell
`compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景 `compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景
@ -679,7 +717,7 @@ cnchar.compareSpell('ao', 'ai') // 返回 'more' 因为 o 排在 i 之后
cnchar.compareSpell('奥', 'ai') // 返回 'more' cnchar.compareSpell('奥', 'ai') // 返回 'more'
``` ```
##### 5.9.5 比较汉字笔画数大小: compareStroke ##### 5.10.5 比较汉字笔画数大小: compareStroke
`compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法 `compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法
@ -699,7 +737,7 @@ cnchar.compareStroke(20, '好') // 返回 'more'
cnchar.compareStroke('一个', '好') // 返回 'less' cnchar.compareStroke('一个', '好') // 返回 'less'
``` ```
##### 5.9.6 根据拼音排序: sortSpell ##### 5.10.6 根据拼音排序: sortSpell
`sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序 `sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序
@ -721,7 +759,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 根据笔画数排序: sortStroke ##### 5.10.7 根据笔画数排序: sortStroke
`sortStroke` 方法用于按照笔画数排序汉字 `sortStroke` 方法用于按照笔画数排序汉字
@ -743,9 +781,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 其他 api #### 5.11 其他 api
##### 5.10.1 .use() ##### 5.11.1 .use()
这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库 这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库
@ -774,9 +812,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord` 参数类型: type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord`、`idiom`、 `xhy`、`radical` 参数类型:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -784,6 +822,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']` spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']`
@ -796,9 +837,17 @@ spellToWordArg 最多可用值: `['simple','trad','poly','alltone','array']`
strokeToWordArg 最多可用值: `['simple','trad','array']` strokeToWordArg 最多可用值: `['simple','trad','array']`
idiomArg 最多可用值: `['char','stroke','spell','tone']`
xhyArg 最多可用值: `['fuzzy','answer','second']`
radicalArg 最多可用值: `['array']`
以上值皆为 json
具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到 具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到
##### 5.10.3 .check ##### 5.11.3 .check
该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true 该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true
@ -808,7 +857,7 @@ strokeToWordArg 最多可用值: `['simple','trad','array']`
cnchar.check = false; // 关闭参数校验 cnchar.check = false; // 关闭参数校验
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
获取当前版本: 获取当前版本:
@ -816,7 +865,7 @@ cnchar.check = false; // 关闭参数校验
var version = cnchar.version; // string 类型 var version = cnchar.version; // string 类型
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]` 当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]`
@ -965,9 +1014,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 | | answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 |
| second | 是否是根据歇后语后一句查询 | 否 | -- | -- | | second | 是否是根据歇后语后一句查询 | 否 | -- | -- |
#### 6.8 使用实例大全: #### 6.8 radical 参数
##### 6.8.0 安装使用 参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
#### 6.9 使用实例大全:
##### 6.9.0 安装使用
npm 方式 npm 方式
@ -989,7 +1050,7 @@ script 标签引用 方式
</script> </script>
``` ```
##### 6.8.1 cnchar 基础库功能 ##### 6.9.1 cnchar 基础库功能
```js ```js
//spell 功能 //spell 功能
@ -1024,7 +1085,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
4. stroke 方法 非中文字符会笔画数会计为 0 4. stroke 方法 非中文字符会笔画数会计为 0
5. stroke 方法 order 模式 非中文字符会返回 undefined 5. stroke 方法 order 模式 非中文字符会返回 undefined
##### 6.8.2 cnchar-poly 库功能 ##### 6.9.2 cnchar-poly 库功能
该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能 该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能
@ -1034,7 +1095,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
'长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order 库功能 ##### 6.9.3 cnchar-order 库功能
该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组 该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组
@ -1090,11 +1151,11 @@ cnchar.orderToWord(['横', '撇', '捺'], 'contain');
// 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的 // 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的
``` ```
##### 6.8.4 cnchar-trad 库功能 ##### 6.9.4 cnchar-trad 库功能
该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持 该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持
###### 6.8.4.1 convert 字体转换 ###### 6.9.4.1 convert 字体转换
```js ```js
'一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad
@ -1116,7 +1177,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell 和 stroke 方法 ###### 6.9.4.2 spell 和 stroke 方法
该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致: 该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致:
@ -1132,7 +1193,7 @@ cnchar.convert.sparkToTrad('①个亾');
'長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]] '長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom 库功能 ##### 6.9.5 cnchar-idiom 库功能
该库为cnchar扩展了成语功能 该库为cnchar扩展了成语功能
@ -1143,7 +1204,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy 库功能 ##### 6.9.6 cnchar-xhy 库功能
该库为cnchar扩展了歇后语功能 该库为cnchar扩展了歇后语功能
@ -1154,18 +1215,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 工具方法 ##### 6.9.7 cnchar-radical 库功能
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 工具方法
cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字 cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1175,7 +1247,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1184,7 +1256,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1196,7 +1268,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1206,7 +1278,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1217,7 +1289,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

View File

@ -1,6 +1,6 @@
{ {
"name": "cnchar-draw", "name": "cnchar-draw",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"unpkg": "cnchar.draw.min.js", "unpkg": "cnchar.draw.min.js",

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ declare type spellArg = 'array' | 'low' | 'up' | 'first' | 'poly' | 'tone' | 'si
declare type strokeArg = 'letter' | 'shape' | 'count' | 'name' | 'detail' | 'array' | 'order' | 'simple' | 'trad'; declare type strokeArg = 'letter' | 'shape' | 'count' | 'name' | 'detail' | 'array' | 'order' | 'simple' | 'trad';
declare type spellToWordArg = 'poly' | 'alltone' | 'array' | 'simple' | 'trad'; declare type spellToWordArg = 'poly' | 'alltone' | 'array' | 'simple' | 'trad';
declare type strokeToWordArg = 'array' | 'simple' | 'trad'; declare type strokeToWordArg = 'array' | 'simple' | 'trad';
declare type pluginArg = 'order' | 'trad' | 'poly' | 'draw' | 'idiom' | 'xhy'; declare type pluginArg = 'order' | 'trad' | 'poly' | 'draw' | 'idiom' | 'xhy' | 'radical';
declare type toneType = 0 | 1 | 2 | 3 | 4; declare type toneType = 0 | 1 | 2 | 3 | 4;
declare type compareType = 'more' | 'less' | 'even'; declare type compareType = 'more' | 'less' | 'even';
@ -35,6 +35,7 @@ export declare interface CnCharStatic {
orderToWord?: object; orderToWord?: object;
idiom?: object; idiom?: object;
xhy?: object; xhy?: object;
radical?: object;
}; };
check: boolean; check: boolean;
readonly version: string; readonly version: string;

View File

@ -1,6 +1,6 @@
{ {
"name": "hanzi-util-base", "name": "hanzi-util-base",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"unpkg": "hanzi.base.min.js", "unpkg": "hanzi.base.min.js",
@ -27,6 +27,6 @@
}, },
"homepage": "https://www.theajack.com/cnchar/", "homepage": "https://www.theajack.com/cnchar/",
"dependencies": { "dependencies": {
"cnchar": "^2.2.4" "cnchar": "^2.2.5"
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{ {
"name": "hanzi-util", "name": "hanzi-util",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"unpkg": "hanzi.util.min.js", "unpkg": "hanzi.util.min.js",
@ -27,6 +27,6 @@
}, },
"homepage": "https://www.theajack.com/cnchar/", "homepage": "https://www.theajack.com/cnchar/",
"dependencies": { "dependencies": {
"cnchar-all": "^2.2.4" "cnchar-all": "^2.2.5"
} }
} }

View File

@ -54,20 +54,21 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword) * [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword)
* [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.9 汉字、拼音工具方法](#59-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) * [5.9 偏旁部首功能](#59-%E5%81%8F%E6%97%81%E9%83%A8%E9%A6%96%E5%8A%9F%E8%83%BD)
+ [5.9.1 查询拼音详细信息: spellInfo](#591-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo) * [5.10 汉字、拼音工具方法](#510-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
+ [5.9.2 拼音音调操作: transformTone](#592-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone) + [5.10.1 查询拼音详细信息: spellInfo](#5101-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo)
+ [5.9.3 是否是汉字: isCnChar](#593-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar) + [5.10.2 拼音音调操作: transformTone](#5102-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone)
+ [5.9.4 比较拼音(汉字)大小: compareSpell](#594-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell) + [5.10.3 是否是汉字: isCnChar](#5103-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar)
+ [5.9.5 比较汉字笔画数大小: compareStroke](#595-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke) + [5.10.4 比较拼音(汉字)大小: compareSpell](#5104-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell)
+ [5.9.6 根据拼音排序: sortSpell](#596-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell) + [5.10.5 比较汉字笔画数大小: compareStroke](#5105-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke)
+ [5.9.7 根据笔画数排序: sortStroke](#597-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke) + [5.10.6 根据拼音排序: sortSpell](#5106-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell)
* [5.10 其他 api](#510-%E5%85%B6%E4%BB%96-api) + [5.10.7 根据笔画数排序: sortStroke](#5107-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke)
+ [5.10.1 .use()](#5101-use) * [5.11 其他 api](#511-%E5%85%B6%E4%BB%96-api)
+ [5.10.2 .type](#5102-type) + [5.11.1 .use()](#5111-use)
+ [5.10.3 .check](#5103-check) + [5.11.2 .type](#5112-type)
+ [5.10.4 .version](#5104-version) + [5.11.3 .check](#5113-check)
+ [5.10.5 .plugins](#5105-plugins) + [5.11.4 .version](#5114-version)
+ [5.11.5 .plugins](#5115-plugins)
- [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0) - [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0)
* [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0) * [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0)
* [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0) * [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0)
@ -76,24 +77,26 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0) * [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0)
* [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0) * [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0)
* [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0) * [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0)
* [6.8 使用实例大全:](#68-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8) * [6.8 radical 参数](#68-radical-%E5%8F%82%E6%95%B0)
+ [6.8.0 安装使用](#680-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8) * [6.9 使用实例大全:](#69-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8)
+ [6.8.1 cnchar 基础库功能](#681-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.0 安装使用](#690-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8)
+ [6.8.2 cnchar-poly 库功能](#682-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.1 cnchar 基础库功能](#691-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.3 cnchar-order 库功能](#683-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.2 cnchar-poly 库功能](#692-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.4 cnchar-trad 库功能](#684-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.3 cnchar-order 库功能](#693-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.1 convert 字体转换](#6841-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2) + [6.9.4 cnchar-trad 库功能](#694-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.2 spell 和 stroke 方法](#6842-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95) - [6.9.4.1 convert 字体转换](#6941-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2)
+ [6.8.5 cnchar-idiom 库功能](#685-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD) - [6.9.4.2 spell 和 stroke 方法](#6942-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95)
+ [6.8.6 cnchar-xhy 库功能](#686-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.5 cnchar-idiom 库功能](#695-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.7 工具方法](#687-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) + [6.9.6 cnchar-xhy 库功能](#696-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.1 spellInfo](#6871-spellinfo) + [6.9.7 cnchar-radical 库功能](#697-cnchar-radical-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.2 isCnChar](#6872-iscnchar) + [6.9.8 工具方法](#698-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
- [6.8.7.3 transformTone](#6873-transformtone) - [6.9.8.1 spellInfo](#6981-spellinfo)
- [6.8.7.4 compareSpell](#6874-comparespell) - [6.9.8.2 isCnChar](#6982-iscnchar)
- [6.8.7.5 compareStroke](#6875-comparestroke) - [6.9.8.3 transformTone](#6983-transformtone)
- [6.8.7.6 sortSpell](#6876-sortspell) - [6.9.8.4 compareSpell](#6984-comparespell)
- [6.8.7.7 sortStroke](#6877-sortstroke) - [6.9.8.5 compareStroke](#6985-comparestroke)
- [6.9.8.6 sortSpell](#6986-sortspell)
- [6.9.8.7 sortStroke](#6987-sortstroke)
- [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90) - [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90)
<!-- tocstop --> <!-- tocstop -->
@ -162,11 +165,12 @@ import cnchar from 'cnchar';
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
### 2.概览 ### 2.概览
@ -181,6 +185,7 @@ import cnchar from 'cnchar';
| cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ | | cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ |
| cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ | | cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ |
| cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| cnchar-radical | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
### 3.安装 ### 3.安装
@ -195,12 +200,12 @@ npm i cnchar
安装附加功能库: 安装附加功能库:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) 当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的四个 或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的所有插件
``` ```
npm i cnchar-all npm i cnchar-all
@ -215,6 +220,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
或使用以下cdn包含了以上七个库 或使用以下cdn包含了以上七个库
@ -238,6 +244,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// 插件请按需取用 // 插件请按需取用
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
@ -258,9 +265,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// 插件请按需取用 // 插件请按需取用
// 注cnchar-draw 在非浏览器环境下不可使用 // 注cnchar-draw 在非浏览器环境下不可使用
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -280,6 +288,7 @@ console.log(cnchar.spell('汉字')); // cnchar api 调用
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -565,6 +574,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
#### 5.8 歇后语功能 #### 5.8 歇后语功能
cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行 cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行
@ -588,11 +599,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 汉字、拼音工具方法 使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
#### 5.9 偏旁部首功能
cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
#### 5.10 汉字、拼音工具方法
cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字 cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字
##### 5.9.1 查询拼音详细信息: spellInfo ##### 5.10.1 查询拼音详细信息: spellInfo
`spellInfo` 方法用于查询拼音的详细信息,用法如下: `spellInfo` 方法用于查询拼音的详细信息,用法如下:
@ -626,7 +664,7 @@ cnchar.spellInfo.tones;
// n 的一声使用 * 代替 // n 的一声使用 * 代替
``` ```
##### 5.9.2 拼音音调操作: transformTone ##### 5.10.2 拼音音调操作: transformTone
`transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调 `transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调
@ -650,7 +688,7 @@ type 为可选参数表示返回值spell设置大小写默认为 'low'
transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng` transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng`
##### 5.9.3 是否是汉字: isCnChar ##### 5.10.3 是否是汉字: isCnChar
`isCnChar` 方法用于判断一个字符是否是汉字 `isCnChar` 方法用于判断一个字符是否是汉字
@ -658,7 +696,7 @@ transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 比较拼音(汉字)大小: compareSpell ##### 5.10.4 比较拼音(汉字)大小: compareSpell
`compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景 `compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景
@ -679,7 +717,7 @@ cnchar.compareSpell('ao', 'ai') // 返回 'more' 因为 o 排在 i 之后
cnchar.compareSpell('奥', 'ai') // 返回 'more' cnchar.compareSpell('奥', 'ai') // 返回 'more'
``` ```
##### 5.9.5 比较汉字笔画数大小: compareStroke ##### 5.10.5 比较汉字笔画数大小: compareStroke
`compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法 `compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法
@ -699,7 +737,7 @@ cnchar.compareStroke(20, '好') // 返回 'more'
cnchar.compareStroke('一个', '好') // 返回 'less' cnchar.compareStroke('一个', '好') // 返回 'less'
``` ```
##### 5.9.6 根据拼音排序: sortSpell ##### 5.10.6 根据拼音排序: sortSpell
`sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序 `sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序
@ -721,7 +759,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 根据笔画数排序: sortStroke ##### 5.10.7 根据笔画数排序: sortStroke
`sortStroke` 方法用于按照笔画数排序汉字 `sortStroke` 方法用于按照笔画数排序汉字
@ -743,9 +781,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 其他 api #### 5.11 其他 api
##### 5.10.1 .use() ##### 5.11.1 .use()
这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库 这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库
@ -774,9 +812,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord` 参数类型: type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord`、`idiom`、 `xhy`、`radical` 参数类型:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -784,6 +822,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']` spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']`
@ -796,9 +837,17 @@ spellToWordArg 最多可用值: `['simple','trad','poly','alltone','array']`
strokeToWordArg 最多可用值: `['simple','trad','array']` strokeToWordArg 最多可用值: `['simple','trad','array']`
idiomArg 最多可用值: `['char','stroke','spell','tone']`
xhyArg 最多可用值: `['fuzzy','answer','second']`
radicalArg 最多可用值: `['array']`
以上值皆为 json
具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到 具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到
##### 5.10.3 .check ##### 5.11.3 .check
该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true 该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true
@ -808,7 +857,7 @@ strokeToWordArg 最多可用值: `['simple','trad','array']`
cnchar.check = false; // 关闭参数校验 cnchar.check = false; // 关闭参数校验
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
获取当前版本: 获取当前版本:
@ -816,7 +865,7 @@ cnchar.check = false; // 关闭参数校验
var version = cnchar.version; // string 类型 var version = cnchar.version; // string 类型
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]` 当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]`
@ -965,9 +1014,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 | | answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 |
| second | 是否是根据歇后语后一句查询 | 否 | -- | -- | | second | 是否是根据歇后语后一句查询 | 否 | -- | -- |
#### 6.8 使用实例大全: #### 6.8 radical 参数
##### 6.8.0 安装使用 参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
#### 6.9 使用实例大全:
##### 6.9.0 安装使用
npm 方式 npm 方式
@ -989,7 +1050,7 @@ script 标签引用 方式
</script> </script>
``` ```
##### 6.8.1 cnchar 基础库功能 ##### 6.9.1 cnchar 基础库功能
```js ```js
//spell 功能 //spell 功能
@ -1024,7 +1085,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
4. stroke 方法 非中文字符会笔画数会计为 0 4. stroke 方法 非中文字符会笔画数会计为 0
5. stroke 方法 order 模式 非中文字符会返回 undefined 5. stroke 方法 order 模式 非中文字符会返回 undefined
##### 6.8.2 cnchar-poly 库功能 ##### 6.9.2 cnchar-poly 库功能
该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能 该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能
@ -1034,7 +1095,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
'长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order 库功能 ##### 6.9.3 cnchar-order 库功能
该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组 该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组
@ -1090,11 +1151,11 @@ cnchar.orderToWord(['横', '撇', '捺'], 'contain');
// 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的 // 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的
``` ```
##### 6.8.4 cnchar-trad 库功能 ##### 6.9.4 cnchar-trad 库功能
该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持 该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持
###### 6.8.4.1 convert 字体转换 ###### 6.9.4.1 convert 字体转换
```js ```js
'一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad
@ -1116,7 +1177,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell 和 stroke 方法 ###### 6.9.4.2 spell 和 stroke 方法
该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致: 该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致:
@ -1132,7 +1193,7 @@ cnchar.convert.sparkToTrad('①个亾');
'長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]] '長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom 库功能 ##### 6.9.5 cnchar-idiom 库功能
该库为cnchar扩展了成语功能 该库为cnchar扩展了成语功能
@ -1143,7 +1204,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy 库功能 ##### 6.9.6 cnchar-xhy 库功能
该库为cnchar扩展了歇后语功能 该库为cnchar扩展了歇后语功能
@ -1154,18 +1215,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 工具方法 ##### 6.9.7 cnchar-radical 库功能
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 工具方法
cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字 cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1175,7 +1247,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1184,7 +1256,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1196,7 +1268,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1206,7 +1278,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1217,7 +1289,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

View File

@ -1,6 +1,6 @@
{ {
"name": "cnchar-idiom", "name": "cnchar-idiom",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"unpkg": "cnchar.idiom.min.js", "unpkg": "cnchar.idiom.min.js",

View File

@ -54,20 +54,21 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword) * [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword)
* [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.9 汉字、拼音工具方法](#59-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) * [5.9 偏旁部首功能](#59-%E5%81%8F%E6%97%81%E9%83%A8%E9%A6%96%E5%8A%9F%E8%83%BD)
+ [5.9.1 查询拼音详细信息: spellInfo](#591-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo) * [5.10 汉字、拼音工具方法](#510-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
+ [5.9.2 拼音音调操作: transformTone](#592-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone) + [5.10.1 查询拼音详细信息: spellInfo](#5101-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo)
+ [5.9.3 是否是汉字: isCnChar](#593-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar) + [5.10.2 拼音音调操作: transformTone](#5102-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone)
+ [5.9.4 比较拼音(汉字)大小: compareSpell](#594-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell) + [5.10.3 是否是汉字: isCnChar](#5103-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar)
+ [5.9.5 比较汉字笔画数大小: compareStroke](#595-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke) + [5.10.4 比较拼音(汉字)大小: compareSpell](#5104-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell)
+ [5.9.6 根据拼音排序: sortSpell](#596-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell) + [5.10.5 比较汉字笔画数大小: compareStroke](#5105-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke)
+ [5.9.7 根据笔画数排序: sortStroke](#597-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke) + [5.10.6 根据拼音排序: sortSpell](#5106-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell)
* [5.10 其他 api](#510-%E5%85%B6%E4%BB%96-api) + [5.10.7 根据笔画数排序: sortStroke](#5107-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke)
+ [5.10.1 .use()](#5101-use) * [5.11 其他 api](#511-%E5%85%B6%E4%BB%96-api)
+ [5.10.2 .type](#5102-type) + [5.11.1 .use()](#5111-use)
+ [5.10.3 .check](#5103-check) + [5.11.2 .type](#5112-type)
+ [5.10.4 .version](#5104-version) + [5.11.3 .check](#5113-check)
+ [5.10.5 .plugins](#5105-plugins) + [5.11.4 .version](#5114-version)
+ [5.11.5 .plugins](#5115-plugins)
- [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0) - [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0)
* [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0) * [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0)
* [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0) * [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0)
@ -76,24 +77,26 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0) * [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0)
* [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0) * [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0)
* [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0) * [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0)
* [6.8 使用实例大全:](#68-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8) * [6.8 radical 参数](#68-radical-%E5%8F%82%E6%95%B0)
+ [6.8.0 安装使用](#680-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8) * [6.9 使用实例大全:](#69-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8)
+ [6.8.1 cnchar 基础库功能](#681-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.0 安装使用](#690-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8)
+ [6.8.2 cnchar-poly 库功能](#682-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.1 cnchar 基础库功能](#691-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.3 cnchar-order 库功能](#683-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.2 cnchar-poly 库功能](#692-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.4 cnchar-trad 库功能](#684-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.3 cnchar-order 库功能](#693-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.1 convert 字体转换](#6841-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2) + [6.9.4 cnchar-trad 库功能](#694-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.2 spell 和 stroke 方法](#6842-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95) - [6.9.4.1 convert 字体转换](#6941-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2)
+ [6.8.5 cnchar-idiom 库功能](#685-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD) - [6.9.4.2 spell 和 stroke 方法](#6942-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95)
+ [6.8.6 cnchar-xhy 库功能](#686-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.5 cnchar-idiom 库功能](#695-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.7 工具方法](#687-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) + [6.9.6 cnchar-xhy 库功能](#696-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.1 spellInfo](#6871-spellinfo) + [6.9.7 cnchar-radical 库功能](#697-cnchar-radical-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.2 isCnChar](#6872-iscnchar) + [6.9.8 工具方法](#698-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
- [6.8.7.3 transformTone](#6873-transformtone) - [6.9.8.1 spellInfo](#6981-spellinfo)
- [6.8.7.4 compareSpell](#6874-comparespell) - [6.9.8.2 isCnChar](#6982-iscnchar)
- [6.8.7.5 compareStroke](#6875-comparestroke) - [6.9.8.3 transformTone](#6983-transformtone)
- [6.8.7.6 sortSpell](#6876-sortspell) - [6.9.8.4 compareSpell](#6984-comparespell)
- [6.8.7.7 sortStroke](#6877-sortstroke) - [6.9.8.5 compareStroke](#6985-comparestroke)
- [6.9.8.6 sortSpell](#6986-sortspell)
- [6.9.8.7 sortStroke](#6987-sortstroke)
- [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90) - [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90)
<!-- tocstop --> <!-- tocstop -->
@ -162,11 +165,12 @@ import cnchar from 'cnchar';
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
### 2.概览 ### 2.概览
@ -181,6 +185,7 @@ import cnchar from 'cnchar';
| cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ | | cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ |
| cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ | | cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ |
| cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| cnchar-radical | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
### 3.安装 ### 3.安装
@ -195,12 +200,12 @@ npm i cnchar
安装附加功能库: 安装附加功能库:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) 当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的四个 或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的所有插件
``` ```
npm i cnchar-all npm i cnchar-all
@ -215,6 +220,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
或使用以下cdn包含了以上七个库 或使用以下cdn包含了以上七个库
@ -238,6 +244,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// 插件请按需取用 // 插件请按需取用
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
@ -258,9 +265,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// 插件请按需取用 // 插件请按需取用
// 注cnchar-draw 在非浏览器环境下不可使用 // 注cnchar-draw 在非浏览器环境下不可使用
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -280,6 +288,7 @@ console.log(cnchar.spell('汉字')); // cnchar api 调用
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -565,6 +574,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
#### 5.8 歇后语功能 #### 5.8 歇后语功能
cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行 cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行
@ -588,11 +599,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 汉字、拼音工具方法 使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
#### 5.9 偏旁部首功能
cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
#### 5.10 汉字、拼音工具方法
cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字 cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字
##### 5.9.1 查询拼音详细信息: spellInfo ##### 5.10.1 查询拼音详细信息: spellInfo
`spellInfo` 方法用于查询拼音的详细信息,用法如下: `spellInfo` 方法用于查询拼音的详细信息,用法如下:
@ -626,7 +664,7 @@ cnchar.spellInfo.tones;
// n 的一声使用 * 代替 // n 的一声使用 * 代替
``` ```
##### 5.9.2 拼音音调操作: transformTone ##### 5.10.2 拼音音调操作: transformTone
`transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调 `transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调
@ -650,7 +688,7 @@ type 为可选参数表示返回值spell设置大小写默认为 'low'
transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng` transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng`
##### 5.9.3 是否是汉字: isCnChar ##### 5.10.3 是否是汉字: isCnChar
`isCnChar` 方法用于判断一个字符是否是汉字 `isCnChar` 方法用于判断一个字符是否是汉字
@ -658,7 +696,7 @@ transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 比较拼音(汉字)大小: compareSpell ##### 5.10.4 比较拼音(汉字)大小: compareSpell
`compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景 `compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景
@ -679,7 +717,7 @@ cnchar.compareSpell('ao', 'ai') // 返回 'more' 因为 o 排在 i 之后
cnchar.compareSpell('奥', 'ai') // 返回 'more' cnchar.compareSpell('奥', 'ai') // 返回 'more'
``` ```
##### 5.9.5 比较汉字笔画数大小: compareStroke ##### 5.10.5 比较汉字笔画数大小: compareStroke
`compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法 `compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法
@ -699,7 +737,7 @@ cnchar.compareStroke(20, '好') // 返回 'more'
cnchar.compareStroke('一个', '好') // 返回 'less' cnchar.compareStroke('一个', '好') // 返回 'less'
``` ```
##### 5.9.6 根据拼音排序: sortSpell ##### 5.10.6 根据拼音排序: sortSpell
`sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序 `sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序
@ -721,7 +759,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 根据笔画数排序: sortStroke ##### 5.10.7 根据笔画数排序: sortStroke
`sortStroke` 方法用于按照笔画数排序汉字 `sortStroke` 方法用于按照笔画数排序汉字
@ -743,9 +781,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 其他 api #### 5.11 其他 api
##### 5.10.1 .use() ##### 5.11.1 .use()
这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库 这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库
@ -774,9 +812,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord` 参数类型: type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord`、`idiom`、 `xhy`、`radical` 参数类型:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -784,6 +822,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']` spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']`
@ -796,9 +837,17 @@ spellToWordArg 最多可用值: `['simple','trad','poly','alltone','array']`
strokeToWordArg 最多可用值: `['simple','trad','array']` strokeToWordArg 最多可用值: `['simple','trad','array']`
idiomArg 最多可用值: `['char','stroke','spell','tone']`
xhyArg 最多可用值: `['fuzzy','answer','second']`
radicalArg 最多可用值: `['array']`
以上值皆为 json
具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到 具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到
##### 5.10.3 .check ##### 5.11.3 .check
该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true 该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true
@ -808,7 +857,7 @@ strokeToWordArg 最多可用值: `['simple','trad','array']`
cnchar.check = false; // 关闭参数校验 cnchar.check = false; // 关闭参数校验
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
获取当前版本: 获取当前版本:
@ -816,7 +865,7 @@ cnchar.check = false; // 关闭参数校验
var version = cnchar.version; // string 类型 var version = cnchar.version; // string 类型
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]` 当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]`
@ -965,9 +1014,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 | | answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 |
| second | 是否是根据歇后语后一句查询 | 否 | -- | -- | | second | 是否是根据歇后语后一句查询 | 否 | -- | -- |
#### 6.8 使用实例大全: #### 6.8 radical 参数
##### 6.8.0 安装使用 参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
#### 6.9 使用实例大全:
##### 6.9.0 安装使用
npm 方式 npm 方式
@ -989,7 +1050,7 @@ script 标签引用 方式
</script> </script>
``` ```
##### 6.8.1 cnchar 基础库功能 ##### 6.9.1 cnchar 基础库功能
```js ```js
//spell 功能 //spell 功能
@ -1024,7 +1085,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
4. stroke 方法 非中文字符会笔画数会计为 0 4. stroke 方法 非中文字符会笔画数会计为 0
5. stroke 方法 order 模式 非中文字符会返回 undefined 5. stroke 方法 order 模式 非中文字符会返回 undefined
##### 6.8.2 cnchar-poly 库功能 ##### 6.9.2 cnchar-poly 库功能
该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能 该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能
@ -1034,7 +1095,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
'长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order 库功能 ##### 6.9.3 cnchar-order 库功能
该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组 该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组
@ -1090,11 +1151,11 @@ cnchar.orderToWord(['横', '撇', '捺'], 'contain');
// 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的 // 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的
``` ```
##### 6.8.4 cnchar-trad 库功能 ##### 6.9.4 cnchar-trad 库功能
该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持 该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持
###### 6.8.4.1 convert 字体转换 ###### 6.9.4.1 convert 字体转换
```js ```js
'一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad
@ -1116,7 +1177,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell 和 stroke 方法 ###### 6.9.4.2 spell 和 stroke 方法
该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致: 该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致:
@ -1132,7 +1193,7 @@ cnchar.convert.sparkToTrad('①个亾');
'長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]] '長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom 库功能 ##### 6.9.5 cnchar-idiom 库功能
该库为cnchar扩展了成语功能 该库为cnchar扩展了成语功能
@ -1143,7 +1204,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy 库功能 ##### 6.9.6 cnchar-xhy 库功能
该库为cnchar扩展了歇后语功能 该库为cnchar扩展了歇后语功能
@ -1154,18 +1215,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 工具方法 ##### 6.9.7 cnchar-radical 库功能
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 工具方法
cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字 cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1175,7 +1247,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1184,7 +1256,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1196,7 +1268,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1206,7 +1278,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1217,7 +1289,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

View File

@ -1,6 +1,6 @@
{ {
"name": "cnchar-order", "name": "cnchar-order",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"unpkg": "cnchar.order.min.js", "unpkg": "cnchar.order.min.js",

View File

@ -54,20 +54,21 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword) * [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword)
* [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.9 汉字、拼音工具方法](#59-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) * [5.9 偏旁部首功能](#59-%E5%81%8F%E6%97%81%E9%83%A8%E9%A6%96%E5%8A%9F%E8%83%BD)
+ [5.9.1 查询拼音详细信息: spellInfo](#591-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo) * [5.10 汉字、拼音工具方法](#510-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
+ [5.9.2 拼音音调操作: transformTone](#592-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone) + [5.10.1 查询拼音详细信息: spellInfo](#5101-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo)
+ [5.9.3 是否是汉字: isCnChar](#593-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar) + [5.10.2 拼音音调操作: transformTone](#5102-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone)
+ [5.9.4 比较拼音(汉字)大小: compareSpell](#594-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell) + [5.10.3 是否是汉字: isCnChar](#5103-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar)
+ [5.9.5 比较汉字笔画数大小: compareStroke](#595-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke) + [5.10.4 比较拼音(汉字)大小: compareSpell](#5104-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell)
+ [5.9.6 根据拼音排序: sortSpell](#596-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell) + [5.10.5 比较汉字笔画数大小: compareStroke](#5105-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke)
+ [5.9.7 根据笔画数排序: sortStroke](#597-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke) + [5.10.6 根据拼音排序: sortSpell](#5106-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell)
* [5.10 其他 api](#510-%E5%85%B6%E4%BB%96-api) + [5.10.7 根据笔画数排序: sortStroke](#5107-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke)
+ [5.10.1 .use()](#5101-use) * [5.11 其他 api](#511-%E5%85%B6%E4%BB%96-api)
+ [5.10.2 .type](#5102-type) + [5.11.1 .use()](#5111-use)
+ [5.10.3 .check](#5103-check) + [5.11.2 .type](#5112-type)
+ [5.10.4 .version](#5104-version) + [5.11.3 .check](#5113-check)
+ [5.10.5 .plugins](#5105-plugins) + [5.11.4 .version](#5114-version)
+ [5.11.5 .plugins](#5115-plugins)
- [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0) - [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0)
* [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0) * [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0)
* [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0) * [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0)
@ -76,24 +77,26 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0) * [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0)
* [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0) * [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0)
* [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0) * [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0)
* [6.8 使用实例大全:](#68-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8) * [6.8 radical 参数](#68-radical-%E5%8F%82%E6%95%B0)
+ [6.8.0 安装使用](#680-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8) * [6.9 使用实例大全:](#69-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8)
+ [6.8.1 cnchar 基础库功能](#681-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.0 安装使用](#690-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8)
+ [6.8.2 cnchar-poly 库功能](#682-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.1 cnchar 基础库功能](#691-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.3 cnchar-order 库功能](#683-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.2 cnchar-poly 库功能](#692-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.4 cnchar-trad 库功能](#684-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.3 cnchar-order 库功能](#693-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.1 convert 字体转换](#6841-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2) + [6.9.4 cnchar-trad 库功能](#694-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.2 spell 和 stroke 方法](#6842-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95) - [6.9.4.1 convert 字体转换](#6941-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2)
+ [6.8.5 cnchar-idiom 库功能](#685-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD) - [6.9.4.2 spell 和 stroke 方法](#6942-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95)
+ [6.8.6 cnchar-xhy 库功能](#686-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.5 cnchar-idiom 库功能](#695-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.7 工具方法](#687-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) + [6.9.6 cnchar-xhy 库功能](#696-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.1 spellInfo](#6871-spellinfo) + [6.9.7 cnchar-radical 库功能](#697-cnchar-radical-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.2 isCnChar](#6872-iscnchar) + [6.9.8 工具方法](#698-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
- [6.8.7.3 transformTone](#6873-transformtone) - [6.9.8.1 spellInfo](#6981-spellinfo)
- [6.8.7.4 compareSpell](#6874-comparespell) - [6.9.8.2 isCnChar](#6982-iscnchar)
- [6.8.7.5 compareStroke](#6875-comparestroke) - [6.9.8.3 transformTone](#6983-transformtone)
- [6.8.7.6 sortSpell](#6876-sortspell) - [6.9.8.4 compareSpell](#6984-comparespell)
- [6.8.7.7 sortStroke](#6877-sortstroke) - [6.9.8.5 compareStroke](#6985-comparestroke)
- [6.9.8.6 sortSpell](#6986-sortspell)
- [6.9.8.7 sortStroke](#6987-sortstroke)
- [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90) - [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90)
<!-- tocstop --> <!-- tocstop -->
@ -162,11 +165,12 @@ import cnchar from 'cnchar';
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
### 2.概览 ### 2.概览
@ -181,6 +185,7 @@ import cnchar from 'cnchar';
| cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ | | cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ |
| cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ | | cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ |
| cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| cnchar-radical | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
### 3.安装 ### 3.安装
@ -195,12 +200,12 @@ npm i cnchar
安装附加功能库: 安装附加功能库:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) 当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的四个 或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的所有插件
``` ```
npm i cnchar-all npm i cnchar-all
@ -215,6 +220,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
或使用以下cdn包含了以上七个库 或使用以下cdn包含了以上七个库
@ -238,6 +244,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// 插件请按需取用 // 插件请按需取用
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
@ -258,9 +265,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// 插件请按需取用 // 插件请按需取用
// 注cnchar-draw 在非浏览器环境下不可使用 // 注cnchar-draw 在非浏览器环境下不可使用
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -280,6 +288,7 @@ console.log(cnchar.spell('汉字')); // cnchar api 调用
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -565,6 +574,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
#### 5.8 歇后语功能 #### 5.8 歇后语功能
cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行 cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行
@ -588,11 +599,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 汉字、拼音工具方法 使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
#### 5.9 偏旁部首功能
cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
#### 5.10 汉字、拼音工具方法
cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字 cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字
##### 5.9.1 查询拼音详细信息: spellInfo ##### 5.10.1 查询拼音详细信息: spellInfo
`spellInfo` 方法用于查询拼音的详细信息,用法如下: `spellInfo` 方法用于查询拼音的详细信息,用法如下:
@ -626,7 +664,7 @@ cnchar.spellInfo.tones;
// n 的一声使用 * 代替 // n 的一声使用 * 代替
``` ```
##### 5.9.2 拼音音调操作: transformTone ##### 5.10.2 拼音音调操作: transformTone
`transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调 `transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调
@ -650,7 +688,7 @@ type 为可选参数表示返回值spell设置大小写默认为 'low'
transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng` transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng`
##### 5.9.3 是否是汉字: isCnChar ##### 5.10.3 是否是汉字: isCnChar
`isCnChar` 方法用于判断一个字符是否是汉字 `isCnChar` 方法用于判断一个字符是否是汉字
@ -658,7 +696,7 @@ transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 比较拼音(汉字)大小: compareSpell ##### 5.10.4 比较拼音(汉字)大小: compareSpell
`compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景 `compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景
@ -679,7 +717,7 @@ cnchar.compareSpell('ao', 'ai') // 返回 'more' 因为 o 排在 i 之后
cnchar.compareSpell('奥', 'ai') // 返回 'more' cnchar.compareSpell('奥', 'ai') // 返回 'more'
``` ```
##### 5.9.5 比较汉字笔画数大小: compareStroke ##### 5.10.5 比较汉字笔画数大小: compareStroke
`compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法 `compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法
@ -699,7 +737,7 @@ cnchar.compareStroke(20, '好') // 返回 'more'
cnchar.compareStroke('一个', '好') // 返回 'less' cnchar.compareStroke('一个', '好') // 返回 'less'
``` ```
##### 5.9.6 根据拼音排序: sortSpell ##### 5.10.6 根据拼音排序: sortSpell
`sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序 `sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序
@ -721,7 +759,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 根据笔画数排序: sortStroke ##### 5.10.7 根据笔画数排序: sortStroke
`sortStroke` 方法用于按照笔画数排序汉字 `sortStroke` 方法用于按照笔画数排序汉字
@ -743,9 +781,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 其他 api #### 5.11 其他 api
##### 5.10.1 .use() ##### 5.11.1 .use()
这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库 这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库
@ -774,9 +812,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord` 参数类型: type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord`、`idiom`、 `xhy`、`radical` 参数类型:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -784,6 +822,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']` spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']`
@ -796,9 +837,17 @@ spellToWordArg 最多可用值: `['simple','trad','poly','alltone','array']`
strokeToWordArg 最多可用值: `['simple','trad','array']` strokeToWordArg 最多可用值: `['simple','trad','array']`
idiomArg 最多可用值: `['char','stroke','spell','tone']`
xhyArg 最多可用值: `['fuzzy','answer','second']`
radicalArg 最多可用值: `['array']`
以上值皆为 json
具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到 具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到
##### 5.10.3 .check ##### 5.11.3 .check
该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true 该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true
@ -808,7 +857,7 @@ strokeToWordArg 最多可用值: `['simple','trad','array']`
cnchar.check = false; // 关闭参数校验 cnchar.check = false; // 关闭参数校验
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
获取当前版本: 获取当前版本:
@ -816,7 +865,7 @@ cnchar.check = false; // 关闭参数校验
var version = cnchar.version; // string 类型 var version = cnchar.version; // string 类型
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]` 当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]`
@ -965,9 +1014,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 | | answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 |
| second | 是否是根据歇后语后一句查询 | 否 | -- | -- | | second | 是否是根据歇后语后一句查询 | 否 | -- | -- |
#### 6.8 使用实例大全: #### 6.8 radical 参数
##### 6.8.0 安装使用 参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
#### 6.9 使用实例大全:
##### 6.9.0 安装使用
npm 方式 npm 方式
@ -989,7 +1050,7 @@ script 标签引用 方式
</script> </script>
``` ```
##### 6.8.1 cnchar 基础库功能 ##### 6.9.1 cnchar 基础库功能
```js ```js
//spell 功能 //spell 功能
@ -1024,7 +1085,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
4. stroke 方法 非中文字符会笔画数会计为 0 4. stroke 方法 非中文字符会笔画数会计为 0
5. stroke 方法 order 模式 非中文字符会返回 undefined 5. stroke 方法 order 模式 非中文字符会返回 undefined
##### 6.8.2 cnchar-poly 库功能 ##### 6.9.2 cnchar-poly 库功能
该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能 该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能
@ -1034,7 +1095,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
'长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order 库功能 ##### 6.9.3 cnchar-order 库功能
该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组 该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组
@ -1090,11 +1151,11 @@ cnchar.orderToWord(['横', '撇', '捺'], 'contain');
// 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的 // 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的
``` ```
##### 6.8.4 cnchar-trad 库功能 ##### 6.9.4 cnchar-trad 库功能
该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持 该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持
###### 6.8.4.1 convert 字体转换 ###### 6.9.4.1 convert 字体转换
```js ```js
'一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad
@ -1116,7 +1177,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell 和 stroke 方法 ###### 6.9.4.2 spell 和 stroke 方法
该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致: 该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致:
@ -1132,7 +1193,7 @@ cnchar.convert.sparkToTrad('①个亾');
'長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]] '長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom 库功能 ##### 6.9.5 cnchar-idiom 库功能
该库为cnchar扩展了成语功能 该库为cnchar扩展了成语功能
@ -1143,7 +1204,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy 库功能 ##### 6.9.6 cnchar-xhy 库功能
该库为cnchar扩展了歇后语功能 该库为cnchar扩展了歇后语功能
@ -1154,18 +1215,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 工具方法 ##### 6.9.7 cnchar-radical 库功能
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 工具方法
cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字 cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1175,7 +1247,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1184,7 +1256,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1196,7 +1268,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1206,7 +1278,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1217,7 +1289,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

View File

@ -1,6 +1,6 @@
{ {
"name": "cnchar-poly", "name": "cnchar-poly",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"unpkg": "cnchar.poly.min.js", "unpkg": "cnchar.poly.min.js",

23
npm/radical/LICENSE Normal file
View File

@ -0,0 +1,23 @@
The MIT License (MIT)
Copyright (c) 2017 - present theajack <contact@theajack.com>
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

1307
npm/radical/README.md Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

15
npm/radical/index.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
declare type radicalArg = 'array';
export declare interface Radical {
(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
}
declare const radical: Radical;
declare module 'cnchar' {
interface CnCharStatic {
radical: Radical;
}
}
export default radical;

36
npm/radical/index.js Normal file
View File

@ -0,0 +1,36 @@
"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _require = require('./radical'),
radical = _require.radical,
arg = _require.arg,
setCnchar = _require.setCnchar;
function main(cnchar) {
if (cnchar.plugins.indexOf('radical') !== -1) {
return;
}
cnchar.plugins.push('radical');
cnchar.radical = radical;
cnchar.type.radical = arg;
}
function init(cnchar) {
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.CncharRadical) {
window.CncharRadical = radical;
}
if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && window.CnChar) {
main(window.CnChar);
setCnchar(window.CnChar);
} else if (typeof cnchar !== 'undefined') {
main(cnchar);
setCnchar(cnchar);
}
}
radical.init = init;
init();
module.exports = radical;

29
npm/radical/package.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "cnchar-radical",
"version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js",
"unpkg": "cnchar.radical.min.js",
"jsdelivr": "cnchar.radical.min.js",
"typings": "index.d.ts",
"scripts": {},
"repository": {
"type": "git",
"url": "git+https://github.com/theajack/cnchar.git"
},
"keywords": [
"汉字拼音",
"汉字笔画数",
"汉字笔画顺序",
"繁体字",
"火星文",
"js库",
"theajack"
],
"author": "theajack",
"license": "MIT",
"bugs": {
"url": "https://github.com/theajack/cnchar/issues"
},
"homepage": "https://www.theajack.com/cnchar/"
}

54
npm/radical/radical.js Normal file
View File

@ -0,0 +1,54 @@
"use strict";
var radicals = require('./radicals.json');
var arg = {
array: 'array'
};
var _cnchar = null;
function radical() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (args.length === 0) {
console.warn('idiom: 请输入搜索项');
return;
}
var input = args[0];
args = args.slice(1);
if (_cnchar) {
_cnchar._.checkArgs('radical', args);
}
var res = '';
for (var i = 0; i < input.length; i++) {
var _char = radicals[input[i]];
if (_char) {
res += _char;
} else {
res += input[i];
}
}
if (args.indexOf(arg.array) !== -1 || input instanceof Array) {
return res.split('');
}
return res;
}
function setCnchar(cnchar) {
_cnchar = cnchar; // initToneCodes(cnchar);
}
module.exports = {
radical: radical,
arg: arg,
setCnchar: setCnchar
};

View File

@ -0,0 +1,195 @@
"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function _wrapRegExp(re, groups) { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _RegExp = _wrapNativeSuper(RegExp); var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = _RegExp.call(this, re, flags); _groups.set(_this, groups || _groups.get(re)); return _this; } _inherits(BabelRegExp, _RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === "string") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } else if (typeof substitution === "function") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = []; args.push.apply(args, arguments); if (_typeof(args[args.length - 1]) !== "object") { args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function buildData() {
var _require = require('fs'),
createReadStream = _require.createReadStream,
fsPromises = _require.promises;
var _require2 = require('path'),
join = _require2.join;
var _require3 = require('readline'),
createInterface = _require3.createInterface;
var wordRegex = /*#__PURE__*/_wrapRegExp(/"word": "(.*)"/, {
word: 1
});
var radicalsRegex = /*#__PURE__*/_wrapRegExp(/"radicals": "(.*)"/, {
radicals: 1
}); // https://raw.githubusercontent.com/pwxcoo/chinese-xinhua/master/data/word.json
var inputPath = join(__dirname, 'word.json');
var outputPath = join(__dirname, 'radicals.json');
return new Promise(function (resolve, reject) {
var words = new Map();
var word = null;
var radicals = null;
var readStream = createReadStream(inputPath, {
encoding: 'utf8',
autoClose: true,
emitClose: true
});
var readLine = createInterface({
input: readStream
});
readStream.on('error', function (err) {
return reject(err);
});
readLine.on('close', function () {
return resolve(words);
});
readLine.on('line', function (line) {
var matches = wordRegex.exec(line);
if (matches && matches.groups) {
word = matches.groups.word;
radicals = null;
} else {
matches = radicalsRegex.exec(line);
if (matches && matches.groups) {
radicals = matches.groups.radicals;
if (word && word.length > 0 && radicals && radicals.length > 0) {
words.set(word, radicals);
}
word = null;
radicals = null;
}
}
});
}).then( /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(words) {
var output, first, _iterator, _step, _step$value, word, radicals;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return fsPromises.open(outputPath, 'w');
case 2:
output = _context.sent;
_context.next = 5;
return output.write('{\n');
case 5:
first = true;
_iterator = _createForOfIteratorHelper(words);
_context.prev = 7;
_iterator.s();
case 9:
if ((_step = _iterator.n()).done) {
_context.next = 21;
break;
}
_step$value = _slicedToArray(_step.value, 2), word = _step$value[0], radicals = _step$value[1];
if (!first) {
_context.next = 17;
break;
}
first = false;
_context.next = 15;
return output.write(" \"".concat(word, "\": \"").concat(radicals, "\""));
case 15:
_context.next = 19;
break;
case 17:
_context.next = 19;
return output.write(",\n \"".concat(word, "\": \"").concat(radicals, "\""));
case 19:
_context.next = 9;
break;
case 21:
_context.next = 26;
break;
case 23:
_context.prev = 23;
_context.t0 = _context["catch"](7);
_iterator.e(_context.t0);
case 26:
_context.prev = 26;
_iterator.f();
return _context.finish(26);
case 29:
_context.next = 31;
return output.write('\n}\n');
case 31:
case "end":
return _context.stop();
}
}
}, _callee, null, [[7, 23, 26, 29]]);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}());
}
buildData().then(function () {
return console.log('完成');
}, function (err) {
return console.error(err);
});

7096
npm/radical/radicals.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -54,20 +54,21 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword) * [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword)
* [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.9 汉字、拼音工具方法](#59-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) * [5.9 偏旁部首功能](#59-%E5%81%8F%E6%97%81%E9%83%A8%E9%A6%96%E5%8A%9F%E8%83%BD)
+ [5.9.1 查询拼音详细信息: spellInfo](#591-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo) * [5.10 汉字、拼音工具方法](#510-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
+ [5.9.2 拼音音调操作: transformTone](#592-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone) + [5.10.1 查询拼音详细信息: spellInfo](#5101-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo)
+ [5.9.3 是否是汉字: isCnChar](#593-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar) + [5.10.2 拼音音调操作: transformTone](#5102-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone)
+ [5.9.4 比较拼音(汉字)大小: compareSpell](#594-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell) + [5.10.3 是否是汉字: isCnChar](#5103-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar)
+ [5.9.5 比较汉字笔画数大小: compareStroke](#595-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke) + [5.10.4 比较拼音(汉字)大小: compareSpell](#5104-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell)
+ [5.9.6 根据拼音排序: sortSpell](#596-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell) + [5.10.5 比较汉字笔画数大小: compareStroke](#5105-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke)
+ [5.9.7 根据笔画数排序: sortStroke](#597-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke) + [5.10.6 根据拼音排序: sortSpell](#5106-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell)
* [5.10 其他 api](#510-%E5%85%B6%E4%BB%96-api) + [5.10.7 根据笔画数排序: sortStroke](#5107-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke)
+ [5.10.1 .use()](#5101-use) * [5.11 其他 api](#511-%E5%85%B6%E4%BB%96-api)
+ [5.10.2 .type](#5102-type) + [5.11.1 .use()](#5111-use)
+ [5.10.3 .check](#5103-check) + [5.11.2 .type](#5112-type)
+ [5.10.4 .version](#5104-version) + [5.11.3 .check](#5113-check)
+ [5.10.5 .plugins](#5105-plugins) + [5.11.4 .version](#5114-version)
+ [5.11.5 .plugins](#5115-plugins)
- [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0) - [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0)
* [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0) * [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0)
* [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0) * [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0)
@ -76,24 +77,26 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0) * [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0)
* [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0) * [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0)
* [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0) * [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0)
* [6.8 使用实例大全:](#68-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8) * [6.8 radical 参数](#68-radical-%E5%8F%82%E6%95%B0)
+ [6.8.0 安装使用](#680-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8) * [6.9 使用实例大全:](#69-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8)
+ [6.8.1 cnchar 基础库功能](#681-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.0 安装使用](#690-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8)
+ [6.8.2 cnchar-poly 库功能](#682-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.1 cnchar 基础库功能](#691-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.3 cnchar-order 库功能](#683-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.2 cnchar-poly 库功能](#692-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.4 cnchar-trad 库功能](#684-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.3 cnchar-order 库功能](#693-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.1 convert 字体转换](#6841-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2) + [6.9.4 cnchar-trad 库功能](#694-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.2 spell 和 stroke 方法](#6842-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95) - [6.9.4.1 convert 字体转换](#6941-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2)
+ [6.8.5 cnchar-idiom 库功能](#685-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD) - [6.9.4.2 spell 和 stroke 方法](#6942-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95)
+ [6.8.6 cnchar-xhy 库功能](#686-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.5 cnchar-idiom 库功能](#695-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.7 工具方法](#687-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) + [6.9.6 cnchar-xhy 库功能](#696-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.1 spellInfo](#6871-spellinfo) + [6.9.7 cnchar-radical 库功能](#697-cnchar-radical-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.2 isCnChar](#6872-iscnchar) + [6.9.8 工具方法](#698-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
- [6.8.7.3 transformTone](#6873-transformtone) - [6.9.8.1 spellInfo](#6981-spellinfo)
- [6.8.7.4 compareSpell](#6874-comparespell) - [6.9.8.2 isCnChar](#6982-iscnchar)
- [6.8.7.5 compareStroke](#6875-comparestroke) - [6.9.8.3 transformTone](#6983-transformtone)
- [6.8.7.6 sortSpell](#6876-sortspell) - [6.9.8.4 compareSpell](#6984-comparespell)
- [6.8.7.7 sortStroke](#6877-sortstroke) - [6.9.8.5 compareStroke](#6985-comparestroke)
- [6.9.8.6 sortSpell](#6986-sortspell)
- [6.9.8.7 sortStroke](#6987-sortstroke)
- [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90) - [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90)
<!-- tocstop --> <!-- tocstop -->
@ -162,11 +165,12 @@ import cnchar from 'cnchar';
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
### 2.概览 ### 2.概览
@ -181,6 +185,7 @@ import cnchar from 'cnchar';
| cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ | | cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ |
| cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ | | cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ |
| cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| cnchar-radical | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
### 3.安装 ### 3.安装
@ -195,12 +200,12 @@ npm i cnchar
安装附加功能库: 安装附加功能库:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) 当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的四个 或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的所有插件
``` ```
npm i cnchar-all npm i cnchar-all
@ -215,6 +220,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
或使用以下cdn包含了以上七个库 或使用以下cdn包含了以上七个库
@ -238,6 +244,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// 插件请按需取用 // 插件请按需取用
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
@ -258,9 +265,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// 插件请按需取用 // 插件请按需取用
// 注cnchar-draw 在非浏览器环境下不可使用 // 注cnchar-draw 在非浏览器环境下不可使用
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -280,6 +288,7 @@ console.log(cnchar.spell('汉字')); // cnchar api 调用
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -565,6 +574,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
#### 5.8 歇后语功能 #### 5.8 歇后语功能
cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行 cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行
@ -588,11 +599,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 汉字、拼音工具方法 使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
#### 5.9 偏旁部首功能
cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
#### 5.10 汉字、拼音工具方法
cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字 cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字
##### 5.9.1 查询拼音详细信息: spellInfo ##### 5.10.1 查询拼音详细信息: spellInfo
`spellInfo` 方法用于查询拼音的详细信息,用法如下: `spellInfo` 方法用于查询拼音的详细信息,用法如下:
@ -626,7 +664,7 @@ cnchar.spellInfo.tones;
// n 的一声使用 * 代替 // n 的一声使用 * 代替
``` ```
##### 5.9.2 拼音音调操作: transformTone ##### 5.10.2 拼音音调操作: transformTone
`transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调 `transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调
@ -650,7 +688,7 @@ type 为可选参数表示返回值spell设置大小写默认为 'low'
transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng` transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng`
##### 5.9.3 是否是汉字: isCnChar ##### 5.10.3 是否是汉字: isCnChar
`isCnChar` 方法用于判断一个字符是否是汉字 `isCnChar` 方法用于判断一个字符是否是汉字
@ -658,7 +696,7 @@ transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 比较拼音(汉字)大小: compareSpell ##### 5.10.4 比较拼音(汉字)大小: compareSpell
`compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景 `compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景
@ -679,7 +717,7 @@ cnchar.compareSpell('ao', 'ai') // 返回 'more' 因为 o 排在 i 之后
cnchar.compareSpell('奥', 'ai') // 返回 'more' cnchar.compareSpell('奥', 'ai') // 返回 'more'
``` ```
##### 5.9.5 比较汉字笔画数大小: compareStroke ##### 5.10.5 比较汉字笔画数大小: compareStroke
`compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法 `compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法
@ -699,7 +737,7 @@ cnchar.compareStroke(20, '好') // 返回 'more'
cnchar.compareStroke('一个', '好') // 返回 'less' cnchar.compareStroke('一个', '好') // 返回 'less'
``` ```
##### 5.9.6 根据拼音排序: sortSpell ##### 5.10.6 根据拼音排序: sortSpell
`sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序 `sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序
@ -721,7 +759,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 根据笔画数排序: sortStroke ##### 5.10.7 根据笔画数排序: sortStroke
`sortStroke` 方法用于按照笔画数排序汉字 `sortStroke` 方法用于按照笔画数排序汉字
@ -743,9 +781,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 其他 api #### 5.11 其他 api
##### 5.10.1 .use() ##### 5.11.1 .use()
这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库 这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库
@ -774,9 +812,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord` 参数类型: type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord`、`idiom`、 `xhy`、`radical` 参数类型:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -784,6 +822,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']` spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']`
@ -796,9 +837,17 @@ spellToWordArg 最多可用值: `['simple','trad','poly','alltone','array']`
strokeToWordArg 最多可用值: `['simple','trad','array']` strokeToWordArg 最多可用值: `['simple','trad','array']`
idiomArg 最多可用值: `['char','stroke','spell','tone']`
xhyArg 最多可用值: `['fuzzy','answer','second']`
radicalArg 最多可用值: `['array']`
以上值皆为 json
具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到 具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到
##### 5.10.3 .check ##### 5.11.3 .check
该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true 该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true
@ -808,7 +857,7 @@ strokeToWordArg 最多可用值: `['simple','trad','array']`
cnchar.check = false; // 关闭参数校验 cnchar.check = false; // 关闭参数校验
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
获取当前版本: 获取当前版本:
@ -816,7 +865,7 @@ cnchar.check = false; // 关闭参数校验
var version = cnchar.version; // string 类型 var version = cnchar.version; // string 类型
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]` 当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]`
@ -965,9 +1014,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 | | answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 |
| second | 是否是根据歇后语后一句查询 | 否 | -- | -- | | second | 是否是根据歇后语后一句查询 | 否 | -- | -- |
#### 6.8 使用实例大全: #### 6.8 radical 参数
##### 6.8.0 安装使用 参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
#### 6.9 使用实例大全:
##### 6.9.0 安装使用
npm 方式 npm 方式
@ -989,7 +1050,7 @@ script 标签引用 方式
</script> </script>
``` ```
##### 6.8.1 cnchar 基础库功能 ##### 6.9.1 cnchar 基础库功能
```js ```js
//spell 功能 //spell 功能
@ -1024,7 +1085,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
4. stroke 方法 非中文字符会笔画数会计为 0 4. stroke 方法 非中文字符会笔画数会计为 0
5. stroke 方法 order 模式 非中文字符会返回 undefined 5. stroke 方法 order 模式 非中文字符会返回 undefined
##### 6.8.2 cnchar-poly 库功能 ##### 6.9.2 cnchar-poly 库功能
该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能 该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能
@ -1034,7 +1095,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
'长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order 库功能 ##### 6.9.3 cnchar-order 库功能
该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组 该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组
@ -1090,11 +1151,11 @@ cnchar.orderToWord(['横', '撇', '捺'], 'contain');
// 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的 // 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的
``` ```
##### 6.8.4 cnchar-trad 库功能 ##### 6.9.4 cnchar-trad 库功能
该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持 该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持
###### 6.8.4.1 convert 字体转换 ###### 6.9.4.1 convert 字体转换
```js ```js
'一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad
@ -1116,7 +1177,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell 和 stroke 方法 ###### 6.9.4.2 spell 和 stroke 方法
该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致: 该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致:
@ -1132,7 +1193,7 @@ cnchar.convert.sparkToTrad('①个亾');
'長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]] '長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom 库功能 ##### 6.9.5 cnchar-idiom 库功能
该库为cnchar扩展了成语功能 该库为cnchar扩展了成语功能
@ -1143,7 +1204,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy 库功能 ##### 6.9.6 cnchar-xhy 库功能
该库为cnchar扩展了歇后语功能 该库为cnchar扩展了歇后语功能
@ -1154,18 +1215,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 工具方法 ##### 6.9.7 cnchar-radical 库功能
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 工具方法
cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字 cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1175,7 +1247,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1184,7 +1256,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1196,7 +1268,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1206,7 +1278,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1217,7 +1289,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

View File

@ -1,6 +1,6 @@
{ {
"name": "cnchar-trad", "name": "cnchar-trad",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"unpkg": "cnchar.trad.min.js", "unpkg": "cnchar.trad.min.js",

View File

@ -54,20 +54,21 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword) * [5.6 通过笔画数查询原汉字: strokeToWord](#56-%E9%80%9A%E8%BF%87%E7%AC%94%E7%94%BB%E6%95%B0%E6%9F%A5%E8%AF%A2%E5%8E%9F%E6%B1%89%E5%AD%97-stroketoword)
* [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.7 成语功能](#57-%E6%88%90%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD) * [5.8 歇后语功能](#58-%E6%AD%87%E5%90%8E%E8%AF%AD%E5%8A%9F%E8%83%BD)
* [5.9 汉字、拼音工具方法](#59-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) * [5.9 偏旁部首功能](#59-%E5%81%8F%E6%97%81%E9%83%A8%E9%A6%96%E5%8A%9F%E8%83%BD)
+ [5.9.1 查询拼音详细信息: spellInfo](#591-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo) * [5.10 汉字、拼音工具方法](#510-%E6%B1%89%E5%AD%97%E6%8B%BC%E9%9F%B3%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
+ [5.9.2 拼音音调操作: transformTone](#592-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone) + [5.10.1 查询拼音详细信息: spellInfo](#5101-%E6%9F%A5%E8%AF%A2%E6%8B%BC%E9%9F%B3%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF-spellinfo)
+ [5.9.3 是否是汉字: isCnChar](#593-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar) + [5.10.2 拼音音调操作: transformTone](#5102-%E6%8B%BC%E9%9F%B3%E9%9F%B3%E8%B0%83%E6%93%8D%E4%BD%9C-transformtone)
+ [5.9.4 比较拼音(汉字)大小: compareSpell](#594-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell) + [5.10.3 是否是汉字: isCnChar](#5103-%E6%98%AF%E5%90%A6%E6%98%AF%E6%B1%89%E5%AD%97-iscnchar)
+ [5.9.5 比较汉字笔画数大小: compareStroke](#595-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke) + [5.10.4 比较拼音(汉字)大小: compareSpell](#5104-%E6%AF%94%E8%BE%83%E6%8B%BC%E9%9F%B3%E6%B1%89%E5%AD%97%E5%A4%A7%E5%B0%8F-comparespell)
+ [5.9.6 根据拼音排序: sortSpell](#596-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell) + [5.10.5 比较汉字笔画数大小: compareStroke](#5105-%E6%AF%94%E8%BE%83%E6%B1%89%E5%AD%97%E7%AC%94%E7%94%BB%E6%95%B0%E5%A4%A7%E5%B0%8F-comparestroke)
+ [5.9.7 根据笔画数排序: sortStroke](#597-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke) + [5.10.6 根据拼音排序: sortSpell](#5106-%E6%A0%B9%E6%8D%AE%E6%8B%BC%E9%9F%B3%E6%8E%92%E5%BA%8F-sortspell)
* [5.10 其他 api](#510-%E5%85%B6%E4%BB%96-api) + [5.10.7 根据笔画数排序: sortStroke](#5107-%E6%A0%B9%E6%8D%AE%E7%AC%94%E7%94%BB%E6%95%B0%E6%8E%92%E5%BA%8F-sortstroke)
+ [5.10.1 .use()](#5101-use) * [5.11 其他 api](#511-%E5%85%B6%E4%BB%96-api)
+ [5.10.2 .type](#5102-type) + [5.11.1 .use()](#5111-use)
+ [5.10.3 .check](#5103-check) + [5.11.2 .type](#5112-type)
+ [5.10.4 .version](#5104-version) + [5.11.3 .check](#5113-check)
+ [5.10.5 .plugins](#5105-plugins) + [5.11.4 .version](#5114-version)
+ [5.11.5 .plugins](#5115-plugins)
- [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0) - [6.spell stroke 参数](#6spell-stroke-%E5%8F%82%E6%95%B0)
* [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0) * [6.1 spell 参数](#61-spell-%E5%8F%82%E6%95%B0)
* [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0) * [6.2 stroke 参数](#62-stroke-%E5%8F%82%E6%95%B0)
@ -76,24 +77,26 @@ cnchar 由于重建过一次仓库,所以之前的 star 清零了 (〒︿〒)
* [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0) * [6.5 strokeToWord 参数](#65-stroketoword-%E5%8F%82%E6%95%B0)
* [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0) * [6.6 idiom 参数](#66-idiom-%E5%8F%82%E6%95%B0)
* [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0) * [6.7 xhy 参数](#67-xhy-%E5%8F%82%E6%95%B0)
* [6.8 使用实例大全:](#68-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8) * [6.8 radical 参数](#68-radical-%E5%8F%82%E6%95%B0)
+ [6.8.0 安装使用](#680-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8) * [6.9 使用实例大全:](#69-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B%E5%A4%A7%E5%85%A8)
+ [6.8.1 cnchar 基础库功能](#681-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.0 安装使用](#690-%E5%AE%89%E8%A3%85%E4%BD%BF%E7%94%A8)
+ [6.8.2 cnchar-poly 库功能](#682-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.1 cnchar 基础库功能](#691-cnchar-%E5%9F%BA%E7%A1%80%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.3 cnchar-order 库功能](#683-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.2 cnchar-poly 库功能](#692-cnchar-poly-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.4 cnchar-trad 库功能](#684-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.3 cnchar-order 库功能](#693-cnchar-order-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.1 convert 字体转换](#6841-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2) + [6.9.4 cnchar-trad 库功能](#694-cnchar-trad-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.4.2 spell 和 stroke 方法](#6842-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95) - [6.9.4.1 convert 字体转换](#6941-convert-%E5%AD%97%E4%BD%93%E8%BD%AC%E6%8D%A2)
+ [6.8.5 cnchar-idiom 库功能](#685-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD) - [6.9.4.2 spell 和 stroke 方法](#6942-spell-%E5%92%8C-stroke-%E6%96%B9%E6%B3%95)
+ [6.8.6 cnchar-xhy 库功能](#686-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD) + [6.9.5 cnchar-idiom 库功能](#695-cnchar-idiom-%E5%BA%93%E5%8A%9F%E8%83%BD)
+ [6.8.7 工具方法](#687-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95) + [6.9.6 cnchar-xhy 库功能](#696-cnchar-xhy-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.1 spellInfo](#6871-spellinfo) + [6.9.7 cnchar-radical 库功能](#697-cnchar-radical-%E5%BA%93%E5%8A%9F%E8%83%BD)
- [6.8.7.2 isCnChar](#6872-iscnchar) + [6.9.8 工具方法](#698-%E5%B7%A5%E5%85%B7%E6%96%B9%E6%B3%95)
- [6.8.7.3 transformTone](#6873-transformtone) - [6.9.8.1 spellInfo](#6981-spellinfo)
- [6.8.7.4 compareSpell](#6874-comparespell) - [6.9.8.2 isCnChar](#6982-iscnchar)
- [6.8.7.5 compareStroke](#6875-comparestroke) - [6.9.8.3 transformTone](#6983-transformtone)
- [6.8.7.6 sortSpell](#6876-sortspell) - [6.9.8.4 compareSpell](#6984-comparespell)
- [6.8.7.7 sortStroke](#6877-sortstroke) - [6.9.8.5 compareStroke](#6985-comparestroke)
- [6.9.8.6 sortSpell](#6986-sortspell)
- [6.9.8.7 sortStroke](#6987-sortstroke)
- [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90) - [7.应用例子](#7%E5%BA%94%E7%94%A8%E4%BE%8B%E5%AD%90)
<!-- tocstop --> <!-- tocstop -->
@ -162,11 +165,12 @@ import cnchar from 'cnchar';
12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能 12. 支持 **繁体字** 拼音、笔画数及以上所有功能,实现和简体字一样的功能
13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语 13. 支持 **成语** 查询功能,可以按照汉字、拼音(声调)、笔画数查询成语
14. 支持 **歇后语** 查询功能,支持模糊查询 14. 支持 **歇后语** 查询功能,支持模糊查询
15. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字** 15. 支持 **偏旁部首** 查询功能
16. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典) 16. 提供汉字工具方法,方便开发者更便捷高效地 **操作拼音和汉字**
17. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境 17. **体积小**min 版本仅 46 kbzip 版本 34 kb (含有大量汉字拼音字典)
18. **typescript支持**支持在typescript中调用 18. **多端可用**,可用于 **浏览器、nodejs、小程序/小游戏、ReactNative/Weex/Uniapp/Electron、webpack**...,支持所有 js 能运行的环境
19. 丰富的配置按功能拆分成7个库按需取用 19. **typescript支持**支持在typescript中调用
20. 丰富的配置按功能拆分成7个库按需取用
### 2.概览 ### 2.概览
@ -181,6 +185,7 @@ import cnchar from 'cnchar';
| cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ | | cnchar-draw | 绘制笔画库 | 支持可视化绘制汉字该库可脱离cnchar使用该库仅在浏览器环境下可用 | 2.1+ |
| cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ | | cnchar-idiom | 成语库 | 支持成语查询等功能 | 2.2+ |
| cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ | | cnchar-xhy | 歇后语库 | 支持歇后语查询等功能 | 2.2+ |
| cnchar-radical | 偏旁部首库 | 支持查询汉字偏旁部首 | 2.2.5+ |
### 3.安装 ### 3.安装
@ -195,12 +200,12 @@ npm i cnchar
安装附加功能库: 安装附加功能库:
``` ```
npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy npm i cnchar-poly cnchar-order cnchar-trad cnchar-draw cnchar-idiom cnchar-xhy cnchar-radical
``` ```
当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy个库可以独立使用) 当然您也可以按需安装其中的几个,但是 `cnchar` 这个基础库是必须安装的draw、idiom、xhy、radical四个库可以独立使用)
或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的四个 或者您可以通过安装`cnchar-all`来使用完整功能,这个库引用了上面的所有插件
``` ```
npm i cnchar-all npm i cnchar-all
@ -215,6 +220,7 @@ npm i cnchar-all
<script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-trad/cnchar.trad.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
``` ```
或使用以下cdn包含了以上七个库 或使用以下cdn包含了以上七个库
@ -238,6 +244,7 @@ import 'cnchar-trad';
import 'cnchar-draw'; import 'cnchar-draw';
import 'cnchar-idiom'; import 'cnchar-idiom';
import 'cnchar-xhy'; import 'cnchar-xhy';
import 'cnchar-radical';
// 插件请按需取用 // 插件请按需取用
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
@ -258,9 +265,10 @@ var order = require('cnchar-order');
var trad = require('cnchar-trad'); var trad = require('cnchar-trad');
var idiom = require('cnchar-idiom'); var idiom = require('cnchar-idiom');
var xhy = require('cnchar-xhy'); var xhy = require('cnchar-xhy');
var radical = require('cnchar-radical');
// 插件请按需取用 // 插件请按需取用
// 注cnchar-draw 在非浏览器环境下不可使用 // 注cnchar-draw 在非浏览器环境下不可使用
cnchar.use(poly, order, trad, idiom, xhy); cnchar.use(poly, order, trad, idiom, xhy, radical);
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -280,6 +288,7 @@ console.log(cnchar.spell('汉字')); // cnchar api 调用
<script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-draw/cnchar.draw.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-idiom/cnchar.idiom.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/cnchar-xhy/cnchar.xhy.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/cnchar-radical/cnchar.radical.min.js"></script>
<script> <script>
console.log('汉字'.spell()); // prototype 方式调用 console.log('汉字'.spell()); // prototype 方式调用
console.log(cnchar.spell('汉字')); // cnchar api 调用 console.log(cnchar.spell('汉字')); // cnchar api 调用
@ -565,6 +574,8 @@ cnchar.idiom('shang', 'spell'); // ["伤风败化", "伤风败俗", ...]
cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ] cnchar.idiom('shang4', 'spell', 'tone'); // ["上兵伐谋", "上不着天,下不着地", ... ]
``` ```
使用cdn引用时会在window对向上暴露 `CncharIdiom` 对象
#### 5.8 歇后语功能 #### 5.8 歇后语功能
cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行 cnchar在2.2.0加入了歇后语功能,启用该功能需要安装 `cnchar-xhy` 功能库该库可以独立于cnchar主库运行
@ -588,11 +599,38 @@ cnchar.xhy('大水', 'fuzzy', 'answer'); // ['泥沙俱下', '后浪推前浪',
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second'); // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
#### 5.9 汉字、拼音工具方法 使用cdn引用时会在window对向上暴露 `CncharXHY` 对象
#### 5.9 偏旁部首功能
cnchar在 2.2.5 加入了偏旁部首功能,启用该功能需要安装 `cnchar-radical` 功能库该库可以独立于cnchar主库运行
感谢 `kewell-tsao` 提供的 pr
使用方式如下:
```ts
cnchar.radical(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
```
看一个具体例子
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
// 返回数组
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
// 传入数组会默认返回数组
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
使用cdn引用时会在window对向上暴露 `CncharRadical` 对象
#### 5.10 汉字、拼音工具方法
cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字 cnchar 将库内部使用的一些操作拼音和汉字的方法整理暴露出来,方便开发者便捷高效的操作拼音和汉字
##### 5.9.1 查询拼音详细信息: spellInfo ##### 5.10.1 查询拼音详细信息: spellInfo
`spellInfo` 方法用于查询拼音的详细信息,用法如下: `spellInfo` 方法用于查询拼音的详细信息,用法如下:
@ -626,7 +664,7 @@ cnchar.spellInfo.tones;
// n 的一声使用 * 代替 // n 的一声使用 * 代替
``` ```
##### 5.9.2 拼音音调操作: transformTone ##### 5.10.2 拼音音调操作: transformTone
`transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调 `transformTone` 方法用于将有音调拼音转换为无音调拼音,且可以获取音调位置和声调
@ -650,7 +688,7 @@ type 为可选参数表示返回值spell设置大小写默认为 'low'
transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng` transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字表示声调,比如 `lv 等价于 lü` `shang4 等价于 shàng`
##### 5.9.3 是否是汉字: isCnChar ##### 5.10.3 是否是汉字: isCnChar
`isCnChar` 方法用于判断一个字符是否是汉字 `isCnChar` 方法用于判断一个字符是否是汉字
@ -658,7 +696,7 @@ transformTone spell参数 支持使用 v 代替 ü,支持使用末尾带数字
cnchar.isCnChar(word: string): boolean; cnchar.isCnChar(word: string): boolean;
``` ```
##### 5.9.4 比较拼音(汉字)大小: compareSpell ##### 5.10.4 比较拼音(汉字)大小: compareSpell
`compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景 `compareSpell` 方法用于按照拼音比较拼音或汉字的大小,可用于通讯录姓名拼音排序等场景
@ -679,7 +717,7 @@ cnchar.compareSpell('ao', 'ai') // 返回 'more' 因为 o 排在 i 之后
cnchar.compareSpell('奥', 'ai') // 返回 'more' cnchar.compareSpell('奥', 'ai') // 返回 'more'
``` ```
##### 5.9.5 比较汉字笔画数大小: compareStroke ##### 5.10.5 比较汉字笔画数大小: compareStroke
`compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法 `compareStroke` 方法用于按照笔画数比较汉字大小,可用于按照姓名首个汉字笔画排序等场景,排序可以参考 `sortStroke` 方法
@ -699,7 +737,7 @@ cnchar.compareStroke(20, '好') // 返回 'more'
cnchar.compareStroke('一个', '好') // 返回 'less' cnchar.compareStroke('一个', '好') // 返回 'less'
``` ```
##### 5.9.6 根据拼音排序: sortSpell ##### 5.10.6 根据拼音排序: sortSpell
`sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序 `sortSpell` 方法用于按照拼音排序汉字或拼音,支持输入数组或字符串,支持按照声调排序、支持倒序
@ -721,7 +759,7 @@ cnchar.sortSpell('你好吗') // '好吗你'
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
##### 5.9.7 根据笔画数排序: sortStroke ##### 5.10.7 根据笔画数排序: sortStroke
`sortStroke` 方法用于按照笔画数排序汉字 `sortStroke` 方法用于按照笔画数排序汉字
@ -743,9 +781,9 @@ cnchar.sortStroke(['一', '三', 2]) // ['一', 2, '三'],
cnchar.sortStroke('一三二', 'desc') // '三二一' cnchar.sortStroke('一三二', 'desc') // '三二一'
``` ```
#### 5.10 其他 api #### 5.11 其他 api
##### 5.10.1 .use() ##### 5.11.1 .use()
这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库 这个 api 的功能是显式启用 `poly`、`order`、`trad` 三个功能库
@ -774,9 +812,9 @@ import 'cnchar-order';
import 'cnchar-trad'; import 'cnchar-trad';
``` ```
##### 5.10.2 .type ##### 5.11.2 .type
type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord` 参数类型: type 对象用户获取当前可用的 `spell``stroke``orderToWord` 、`spellToWord`、`strokeToWord`、`idiom`、 `xhy`、`radical` 参数类型:
```js ```js
var spellArg = cnchar.type.spell; var spellArg = cnchar.type.spell;
@ -784,6 +822,9 @@ var strokeArg = cnchar.type.stroke;
var orderToWordArg = cnchar.type.orderToWord; var orderToWordArg = cnchar.type.orderToWord;
var spellToWordArg = cnchar.type.spellToWord; var spellToWordArg = cnchar.type.spellToWord;
var strokeToWordArg = cnchar.type.strokeToWord; var strokeToWordArg = cnchar.type.strokeToWord;
var idiomArg = cnchar.type.idiom;
var xhyArg = cnchar.type.xhy;
var radicalArg = cnchar.type.radical;
``` ```
spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']` spellArg 最多可用值: `['array', 'low', 'up', 'first', 'poly', 'tone', 'simple']`
@ -796,9 +837,17 @@ spellToWordArg 最多可用值: `['simple','trad','poly','alltone','array']`
strokeToWordArg 最多可用值: `['simple','trad','array']` strokeToWordArg 最多可用值: `['simple','trad','array']`
idiomArg 最多可用值: `['char','stroke','spell','tone']`
xhyArg 最多可用值: `['fuzzy','answer','second']`
radicalArg 最多可用值: `['array']`
以上值皆为 json
具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到 具体用法<a href="#user-content-6-spell-stroke-参数">第六章</a>讲到
##### 5.10.3 .check ##### 5.11.3 .check
该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true 该值是一个 布尔类型,用于控制是否开启参数校验,默认值为 true
@ -808,7 +857,7 @@ strokeToWordArg 最多可用值: `['simple','trad','array']`
cnchar.check = false; // 关闭参数校验 cnchar.check = false; // 关闭参数校验
``` ```
##### 5.10.4 .version ##### 5.11.4 .version
获取当前版本: 获取当前版本:
@ -816,7 +865,7 @@ cnchar.check = false; // 关闭参数校验
var version = cnchar.version; // string 类型 var version = cnchar.version; // string 类型
``` ```
##### 5.10.5 .plugins ##### 5.11.5 .plugins
当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]` 当前使用的功能库列表,最多的情况为 `["order", "trad", "poly"]`
@ -965,9 +1014,21 @@ cnchar.xhy(value,arg1,arg2,...);
| answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 | | answer | 是否只输出答案 | 否 | -- | 默认是输出整句歇后语 |
| second | 是否是根据歇后语后一句查询 | 否 | -- | -- | | second | 是否是根据歇后语后一句查询 | 否 | -- | -- |
#### 6.8 使用实例大全: #### 6.8 radical 参数
##### 6.8.0 安装使用 参数调用如下value表示需要查询偏旁的汉字可以是字符串或数组
```js
cnchar.radical(value,arg1,arg2,...);
```
| 参数 | 作用 | 是否默认 | 依赖库 | 备注 |
| :-----: | :----: | :------: | :---: | :---: |
| array | 是否返回数组 | 否 | -- | 当传入为数组时默认返回数组 |
#### 6.9 使用实例大全:
##### 6.9.0 安装使用
npm 方式 npm 方式
@ -989,7 +1050,7 @@ script 标签引用 方式
</script> </script>
``` ```
##### 6.8.1 cnchar 基础库功能 ##### 6.9.1 cnchar 基础库功能
```js ```js
//spell 功能 //spell 功能
@ -1024,7 +1085,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
4. stroke 方法 非中文字符会笔画数会计为 0 4. stroke 方法 非中文字符会笔画数会计为 0
5. stroke 方法 order 模式 非中文字符会返回 undefined 5. stroke 方法 order 模式 非中文字符会返回 undefined
##### 6.8.2 cnchar-poly 库功能 ##### 6.9.2 cnchar-poly 库功能
该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能 该库用于准确识别多音词,同样支持 6.3.1 中的其他参数功能
@ -1034,7 +1095,7 @@ cnchar.strokeToWord(2); // 返回 "丁七乃乜九了二人亻儿入八冂几凵
'长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)' '长大了'.spell('poly'); // 返回 '(Zhang|Chang)(Da|Dai)(Le|Liao)'
``` ```
##### 6.8.3 cnchar-order 库功能 ##### 6.9.3 cnchar-order 库功能
该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组 该库用于查询汉字笔画顺序、笔画名称等,返回值为 数组
@ -1090,11 +1151,11 @@ cnchar.orderToWord(['横', '撇', '捺'], 'contain');
// 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的 // 返回 "丈大天太夫夭尺攵文犬仗叭史央夯失疋矢乔..." // 省略后面的
``` ```
##### 6.8.4 cnchar-trad 库功能 ##### 6.9.4 cnchar-trad 库功能
该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持 该库用于支持繁体字火星文转换及为拼音笔画数等基本功能提供繁体字支持
###### 6.8.4.1 convert 字体转换 ###### 6.9.4.1 convert 字体转换
```js ```js
'一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad '一个人'.convertSimpleToTrad(); // 返回 "壹個人" 等价于 cnchar.convert.simpleToTrad
@ -1116,7 +1177,7 @@ cnchar.convert.sparkToSimple('①个亾');
cnchar.convert.sparkToTrad('①个亾'); cnchar.convert.sparkToTrad('①个亾');
``` ```
###### 6.8.4.2 spell 和 stroke 方法 ###### 6.9.4.2 spell 和 stroke 方法
该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致: 该库增加了对于繁体字的拼音笔画功能扩展,其他基础用法与 基础库一致:
@ -1132,7 +1193,7 @@ cnchar.convert.sparkToTrad('①个亾');
'長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]] '長大'.stroke('order', 'shape', 'simple'); // 返回 [undefined, ["㇐","","㇏"]]
``` ```
##### 6.8.5 cnchar-idiom 库功能 ##### 6.9.5 cnchar-idiom 库功能
该库为cnchar扩展了成语功能 该库为cnchar扩展了成语功能
@ -1143,7 +1204,7 @@ cnchar.idiom('shang', 'spell') // ['伤风败化', '伤风败俗', ... ]
cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ] cnchar.idiom('shang4', 'spell', 'tone') // ['伤风败化', '伤风败俗', ... ]
``` ```
##### 6.8.6 cnchar-xhy 库功能 ##### 6.9.6 cnchar-xhy 库功能
该库为cnchar扩展了歇后语功能 该库为cnchar扩展了歇后语功能
@ -1154,18 +1215,29 @@ cnchar.xhy('大水', 'fuzzy', 'answer') // ['泥沙俱下', '后浪推前浪', .
cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥'] cnchar.xhy('上晃下摇', 'fuzzy', 'answer', 'second') // ['醉汉过铁索桥', '扶着醉汉过破桥']
``` ```
##### 6.8.7 工具方法 ##### 6.9.7 cnchar-radical 库功能
该库为cnchar扩展了偏旁部首功能
```js
cnchar.radical('你'); // "亻",
cnchar.radical('你好呀'); // "亻女口"
cnchar.radical('你好呀', 'array'); // ["亻", "女", "口"]
cnchar.radical(["你", "好", "呀"]); // ["亻", "女", "口"]
```
##### 6.9.8 工具方法
cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字 cnchar提供了一些汉字工具方法方便开发者更便捷高效地操作拼音和汉字
###### 6.8.7.1 spellInfo ###### 6.9.8.1 spellInfo
```js ```js
cnchar.spellInfo('shàng'); cnchar.spellInfo('shàng');
// 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"} // 返回 {spell: "shang", tone: 4, index: 3, initial: "sh", final: "ang"}
``` ```
###### 6.8.7.2 isCnChar ###### 6.9.8.2 isCnChar
```js ```js
cnchar.isCnChar('a') // false cnchar.isCnChar('a') // false
@ -1175,7 +1247,7 @@ cnchar.isCnChar('国') // true
cnchar.isCnChar('國') // true cnchar.isCnChar('國') // true
``` ```
###### 6.8.7.3 transformTone ###### 6.9.8.3 transformTone
```js ```js
cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true} cnchar.transformTone('lv2') // {spell: 'lü', tone: 2, index: 2, isTrans: true}
@ -1184,7 +1256,7 @@ cnchar.transformTone('lv2', true, 'up') // {spell: 'LǗ', tone: 2, index: 2, isT
cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false} cnchar.transformTone('lǘ') // {spell: 'lü', tone: 2, index: 2, isTrans: false}
``` ```
###### 6.8.7.4 compareSpell ###### 6.9.8.4 compareSpell
```js ```js
cnchar.compareSpell('ao', 'ai') // 'more' cnchar.compareSpell('ao', 'ai') // 'more'
@ -1196,7 +1268,7 @@ cnchar.compareSpell('品', '频', true) // 'more'
cnchar.compareSpell('贫', '频', true) // 'even' cnchar.compareSpell('贫', '频', true) // 'even'
``` ```
###### 6.8.7.5 compareStroke ###### 6.9.8.5 compareStroke
```js ```js
cnchar.compareStroke('你', '好') // 'more' cnchar.compareStroke('你', '好') // 'more'
@ -1206,7 +1278,7 @@ cnchar.compareStroke('一个', '好') // 'less'
cnchar.compareStroke('你', 14) // 'less' cnchar.compareStroke('你', 14) // 'less'
``` ```
###### 6.8.7.6 sortSpell ###### 6.9.8.6 sortSpell
```js ```js
cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你'] cnchar.sortSpell(['你', '好', '吗']) // ['好', '吗', '你']
@ -1217,7 +1289,7 @@ cnchar.sortSpell(['拼', '品', '频', '爱'], 'tone', 'desc') // ['品', '频',
cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱' cnchar.sortSpell('拼品频爱', 'tone', 'desc') // '品频拼爱'
``` ```
###### 6.8.7.7 sortStroke ###### 6.9.8.7 sortStroke
```js ```js
cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三'] cnchar.sortStroke(['一', '三', '二']) // ['一', '二', '三']

View File

@ -1,6 +1,6 @@
{ {
"name": "cnchar-xhy", "name": "cnchar-xhy",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.js", "main": "index.js",
"unpkg": "cnchar.xhy.min.js", "unpkg": "cnchar.xhy.min.js",

View File

@ -1,6 +1,6 @@
{ {
"name": "cnchar", "name": "cnchar",
"version": "2.2.4", "version": "2.2.5",
"description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文", "description": "功能全面、多端支持的汉字拼音笔画js库支持多音字、繁体字、火星文",
"main": "index.html", "main": "index.html",
"author": "theajack <contact@theajack.com>", "author": "theajack <contact@theajack.com>",

View File

@ -5,6 +5,7 @@ import '../src/plugin/poly';
import '../src/plugin/draw'; import '../src/plugin/draw';
import '../src/plugin/idiom'; import '../src/plugin/idiom';
import '../src/plugin/xhy'; import '../src/plugin/xhy';
import '../src/plugin/radical';
// import spell from '../src/main/spell-dict-jian.json'; // import spell from '../src/main/spell-dict-jian.json';
// // import cncharDraw from '../src/plugin/draw'; // // import cncharDraw from '../src/plugin/draw';

3
src/main/index.d.ts vendored
View File

@ -4,7 +4,7 @@ declare type spellArg = 'array' | 'low' | 'up' | 'first' | 'poly' | 'tone' | 'si
declare type strokeArg = 'letter' | 'shape' | 'count' | 'name' | 'detail' | 'array' | 'order' | 'simple' | 'trad'; declare type strokeArg = 'letter' | 'shape' | 'count' | 'name' | 'detail' | 'array' | 'order' | 'simple' | 'trad';
declare type spellToWordArg = 'poly' | 'alltone' | 'array' | 'simple' | 'trad'; declare type spellToWordArg = 'poly' | 'alltone' | 'array' | 'simple' | 'trad';
declare type strokeToWordArg = 'array' | 'simple' | 'trad'; declare type strokeToWordArg = 'array' | 'simple' | 'trad';
declare type pluginArg = 'order' | 'trad' | 'poly' | 'draw' | 'idiom' | 'xhy'; declare type pluginArg = 'order' | 'trad' | 'poly' | 'draw' | 'idiom' | 'xhy' | 'radical';
declare type toneType = 0 | 1 | 2 | 3 | 4; declare type toneType = 0 | 1 | 2 | 3 | 4;
declare type compareType = 'more' | 'less' | 'even'; declare type compareType = 'more' | 'less' | 'even';
@ -35,6 +35,7 @@ export declare interface CnCharStatic {
orderToWord?: object; orderToWord?: object;
idiom?: object; idiom?: object;
xhy?: object; xhy?: object;
radical?: object;
}; };
check: boolean; check: boolean;
readonly version: string; readonly version: string;

View File

@ -299,6 +299,8 @@ function checkArgs (type, args, jumpNext) {
} }
} else if (type === 'xhy') { } else if (type === 'xhy') {
} else if (type === 'radical') {
} }
warnArgs(useless, '无效', type); warnArgs(useless, '无效', type);
warnArgs(ignore, '被忽略', type); warnArgs(ignore, '被忽略', type);

View File

@ -1 +1 @@
module.exports = '2.2.4'; module.exports = '2.2.5';

15
src/plugin/radical/index.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
declare type radicalArg = 'array';
export declare interface Radical {
(text:string | Array<string>, ...radicalArgs: Array<radicalArg>): string | Array<string>;
}
declare const radical: Radical;
declare module 'cnchar' {
interface CnCharStatic {
radical: Radical;
}
}
export default radical;

View File

@ -1,25 +1,30 @@
const radicals = require('./radicals.json');
function main(cnchar) { const {radical, arg, setCnchar} = require('./radical');
function main (cnchar) {
if (cnchar.plugins.indexOf('radical') !== -1) { if (cnchar.plugins.indexOf('radical') !== -1) {
return; return;
} }
cnchar.plugins.push('radical'); cnchar.plugins.push('radical');
cnchar.radical = radical; cnchar.radical = radical;
cnchar.type.radical = arg;
} }
function init(cnchar) { function init (cnchar) {
if (typeof window === 'object' && !window.CncharRadical) {
window.CncharRadical = radical;
}
if (typeof window === 'object' && window.CnChar) { if (typeof window === 'object' && window.CnChar) {
main(window.CnChar); main(window.CnChar);
setCnchar(window.CnChar);
} else if (typeof cnchar !== 'undefined') { } else if (typeof cnchar !== 'undefined') {
main(cnchar); main(cnchar);
setCnchar(cnchar);
} }
} }
function radical(char) { radical.init = init;
return radicals[char];
}
init(); init();
module.exports = init; module.exports = radical;

View File

@ -0,0 +1,44 @@
const radicals = require('./radicals.json');
let arg = {
array: 'array'
};
let _cnchar = null;
function radical (...args) {
if (args.length === 0) {
console.warn('idiom: 请输入搜索项');
return;
}
let input = args[0];
args = args.slice(1);
if (_cnchar) {
_cnchar._.checkArgs('radical', args);
}
let res = '';
for (let i = 0; i < input.length; i++) {
let char = radicals[input[i]];
if (char) {
res += char;
} else {
res += input[i];
}
}
if (args.indexOf(arg.array) !== -1 || input instanceof Array) {
return res.split('');
}
return res;
}
function setCnchar (cnchar) {
_cnchar = cnchar;
// initToneCodes(cnchar);
}
module.exports = {
radical,
arg,
setCnchar
};

View File

@ -1,7 +1,7 @@
function buildData() { function buildData () {
const { createReadStream, promises: fsPromises } = require('fs'); const {createReadStream, promises: fsPromises} = require('fs');
const { join } = require('path'); const {join} = require('path');
const { createInterface } = require('readline'); const {createInterface} = require('readline');
const wordRegex = /"word": "(?<word>.*)"/; const wordRegex = /"word": "(?<word>.*)"/;
const radicalsRegex = /"radicals": "(?<radicals>.*)"/; const radicalsRegex = /"radicals": "(?<radicals>.*)"/;
// https://raw.githubusercontent.com/pwxcoo/chinese-xinhua/master/data/word.json // https://raw.githubusercontent.com/pwxcoo/chinese-xinhua/master/data/word.json
@ -16,7 +16,7 @@ function buildData() {
autoClose: true, autoClose: true,
emitClose: true, emitClose: true,
}); });
const readLine = createInterface({ input: readStream }); const readLine = createInterface({input: readStream});
readStream.on('error', (err) => reject(err)); readStream.on('error', (err) => reject(err));
readLine.on('close', () => resolve(words)); readLine.on('close', () => resolve(words));
readLine.on('line', (line) => { readLine.on('line', (line) => {

View File

@ -1,4 +1,4 @@
let order, trad, poly, idiom, xhy, cnchar; let order, trad, poly, idiom, xhy, radical, cnchar;
if (process.argv[2] === 'npm') { if (process.argv[2] === 'npm') {
cnchar = require('../npm/cnchar'); cnchar = require('../npm/cnchar');
@ -7,6 +7,7 @@ if (process.argv[2] === 'npm') {
poly = require('../npm/poly'); poly = require('../npm/poly');
idiom = require('../npm/idiom'); idiom = require('../npm/idiom');
xhy = require('../npm/xhy'); xhy = require('../npm/xhy');
radical = require('../npm/radical');
console.log('****TEST NPM****'); console.log('****TEST NPM****');
} else { } else {
cnchar = require('../src/main/index'); cnchar = require('../src/main/index');
@ -15,11 +16,12 @@ if (process.argv[2] === 'npm') {
poly = require('../src/plugin/poly'); poly = require('../src/plugin/poly');
idiom = require('../src/plugin/idiom'); idiom = require('../src/plugin/idiom');
xhy = require('../src/plugin/xhy'); xhy = require('../src/plugin/xhy');
radical = require('../src/plugin/radical');
console.log('****TEST SRC****'); console.log('****TEST SRC****');
} }
console.log(); console.log();
cnchar.use(order, trad, poly, idiom, xhy); cnchar.use(order, trad, poly, idiom, xhy, radical);
let config = require('./test.config'); let config = require('./test.config');

View File

@ -297,5 +297,22 @@ module.exports = [
['一', 2, '三'], ['一', 2, '三'],
['三', '二', '一'] ['三', '二', '一']
] ]
},
{
name: '测试偏旁部首',
test (cnchar) {
return [
cnchar.radical('你'),
cnchar.radical('你好呀'),
cnchar.radical('你好呀', 'array'),
cnchar.radical(['你', '好', '呀']),
];
},
expect: [
'亻',
'亻女口',
['亻', '女', '口'],
['亻', '女', '口']
]
} }
]; ];