Bladeren bron

按拼音搜索

lilei 3 jaren geleden
bovenliggende
commit
3352099082
1 gewijzigde bestanden met toevoegingen van 4 en 2 verwijderingen
  1. 4 2
      src/views/common/productBrand.js

+ 4 - 2
src/views/common/productBrand.js

@@ -11,7 +11,7 @@ const ProductBrand = {
         option-filter-prop="children"
         :dropdownMatchSelectWidth="false"
         :filter-option="filterOption">
-        <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
+        <a-select-option v-for="item in productBrandList" :pinyin="item.pinyin" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
       </a-select>
     `,
   props: {
@@ -44,8 +44,10 @@ const ProductBrand = {
   },
   methods: {
     filterOption (input, option) {
+      console.log(input, option.data.attrs.pinyin)
       return (
-        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
+        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 || 
+        option.data.attrs.pinyin.toLowerCase().indexOf(input.toLowerCase()) >= 0
       )
     },
     handleChange(value) {