今天產品老哥提了個要求輸入框既支持下拉選擇又要支持輸入并且支持根據輸入項過濾條目,當時想著使用el-select就能輕松完成呢,結果廢了老半天的時間也沒能實現,最后選擇了el-autocomplete
官方文檔中給的demo中是根據字符串頭查詢,并不能實現模糊查詢
把return?(link.value.toLowerCase().indexOf(queryString.toLowerCase())?===?0);改為return?(link.value.toLowerCase().indexOf(queryString.toLowerCase()) != -1);就可以實現模糊查詢了
下面是兩次查詢結果的對比