vue组件model应用

Vue.component('weiji-input', {
    model: {
        prop: 'wjlx',
        event:'selectweiji'
    },
    props:['wjlx'],
    data: function () {
        return {
        };
    },
    computed:{
        lx: {
            get: function () {
                return this.wjlx;
            },
            set: function (val) {
                this.$emit('selectweiji', val);
            }
        }
    },
    methods: {
        querySearch: function (queryString, cb) {
            var restaurants = this.loadAll();
            var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
            cb(results);
        },
        createFilter(queryString) {
            return (restaurant) => {
                return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
            };
        },
        loadAll: function () {
            return [{ value: '警告' }, { value: '严重警告' }, { value: '记过' }, { value: '作弊' }, { value: '留校察看' }, { value: '勒令退学' }, { value: '开除学籍' }];
        }
    },
    template: '\
            '
});

调用示例:


你可能感兴趣的:(vue-js)