前端拼音(汉字)检索,好用的插件 pinyin-match

目录

  • 安装插件pinyin-match
  • js引入
  • 能够实现的方法
  • 一些地址
    • pinyin-match的github 地址
    • 在线演练地址
    • 具体实现文档

安装插件pinyin-match

npm install pinyin-match --save

js引入

需要使用的文件位置进行引入
import PinyinMatch from ‘pinyin-match’;

能够实现的方法

let test = ‘123曾经沧海难为水除却巫山不是云’

PinyinMatch.match(test, ‘23曾’); // [1, 3]

PinyinMatch.match(test, ‘cjc’) // [3, 5]

PinyinMatch.match(test, ‘cengjingcanghai’) // [3, 6]

PinyinMatch.match(test, ‘cengjingcangha’) // [3, 6]

PinyinMatch.match(test, ‘engjingcanghai’) // false

PinyinMatch.match(test, ‘zengjingcang’) // [3, 5]

PinyinMatch.match(test, ‘sdjkelwqf’) // false

PinyinMatch.match(test, ‘zengji ng cang’) // [3, 5]

PinyinMatch.match(test, ‘zengji ng cangsdjfkl’) // false

PinyinMatch.match(’ 我 爱你 中 国 ', ‘nzg’) // [6, 12]

PinyinMatch.match(’ 我 爱你 中 国 ', ‘爱你中’) // [5, 8]

PinyinMatch.match(‘發’, ‘fa’) // [0, 0]

一些地址

pinyin-match的github 地址

https://github.com/xmflswood/pinyin-match

在线演练地址

http://laosep.top/pinyin-match;

具体实现文档

https://juejin.cn/post/6844904161461403661

你可能感兴趣的:(前端,前端,javascript,vue.js)