vue 公用组件

时间:2020-04-22
本文章向大家介绍vue 公用组件,主要包括vue 公用组件使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
Vue.component("publicselect", {
    props: {
        value: { type: Array, default: [] },
        multiple: { type: Boolean, default: false },
        dataId: { type: String, default: "" },
        showtype: { type: String, default: 'all' },
        dis: { type: Boolean, default: false }
    },
    data: function () {
        return {
            datals: [],
            loading: true,
            value2: []
        };
    },
    watch: {

       
    },
    methods: {
        remoteMethod(keyword) {
            
        },
        select(va) {

            if (va == '') {
                this.$emit("input", []);
                this.$emit("change", []);
            }
            else {
                this.$emit("input", [va]);
                this.$emit("change", [va]);
            }
        }
    },
    created() {

        

    },
    template: `
    <el-select
    v-model="value2"
    clearable 
    filterable
    remote
    @change='select'
    reserve-keyword
    placeholder="请输入"
    :disabled="dis"
    :remote-method="remoteMethod"
    :loading="loading">
    <el-option
      v-for="item in datals"
      :key="item.Id"
      :label="item"
      :value="item">
    </el-option>
  </el-select>
    `
});
在main.js中定义,通过import引入

原文地址:https://www.cnblogs.com/HKSam/p/12753050.html