1.下载拼音码包导入进来
npm install --save pinyin
import pinyin from 'pinyin'
2.修改element el-select 源码
import {
escapeRegexpString //这个方法是element el-select 检索方法 导入进来
} from 'element-ui/src/utils/util'
ElementUI.Option.methods.queryChange = function (query) {
const reg = new RegExp(escapeRegexpString(query), 'i')
const firstLetter = pinyin(this.currentLabel, {
style: pinyin.STYLE_FIRST_LETTER
}).join('')
this.visible = reg.test(this.currentLabel) || reg.test(firstLetter) || this.created
if (!this.visible) {
this.select.filteredOptionsCount--
}
}
Vue.use(ElementUI)
版权声明:本文为bossxu_原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。