由于项目在大陆和台湾同胞同步使用,因此需要实现中文的简繁体转换,实现输入简体,能搜索出简体和繁体的相关内容,输入繁体,也能搜索出简繁体相关内容。忽略简繁体,扩大搜索范围。
引入插件:
npm install chinese-conv
方法封装:
conv.ts
import chineseConv from "chinese-conv";
// 繁体转简体
export function c(text: string) {
return text ? chineseConv.sify(text) : text;
}
// 简体转繁体
export function t(text: string) {
return text ? chineseConv.tify(text) : text;
}
使用:

过滤的时候,使用该简繁体转换的函数即可,将简繁体相关的内容都返回出来




![[牛客网]——C语言刷题day4](https://img-blog.csdnimg.cn/direct/f645835f7037497099f6a77ed52cd21d.png)













![[通俗易懂]《动手学强化学习》学习笔记3-第5-13章](https://img-blog.csdnimg.cn/direct/f4a454a80b834a68a0c6941a2adc4370.png)

