实例化CSS material_select()无需自动排序

时间:2018-08-10 15:17:39

标签: javascript vue.js materialize

例如,如果myObj.category_ids等于Array(3) [3, 1 ,2]
并且(3 = cat | 1 = cat1 | 2 = cat2)

显示为cat3,cat2,cat1

我想要cat3,cat1,cat2(如数组ID顺序)

enter image description here

MyCode:

<select id="lstCategories" multiple v-model="myObj.category_ids">
    <option value="" disabled>Choose item</option>
    <option v-for="category in lstCategories" :value="category.id" :key="category.id">{{ category.name }}</option>
</select>

Vue数据:

data() {
    return {

        lstCategories: {},

        myObj: {
            category_ids: [],
        },

    }
},

Vue挂载功能:

 mounted() {
       $('#lstCategories').material_select();            
}

Vue Watch功能:

  watch: {
            lstCategories: function (newVal, oldVal) {
                this.$nextTick(function () {
                    //now, DOM will have been updated.
                    $('#lstCategories').material_select(); 
                })
            }
        },

我认为material_select我希望对其进行自动排序。

版本:实现v0.100.1

0 个答案:

没有答案