1.下载拼音码包导入进来
npm install --save pinyin
import pinyin from 'pinyin'
2.修改element el-select 源码
import {
escapeRegexpString
} 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)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a2ecb317678c28012a70fc656141d632.png)