customSelectorsDictionary.vue 842 Bytes
<template>
  <el-select v-if="options" v-model="selectVal" placeholder="请选择">
    <el-option
      v-for="item in options"
      :key="item[valueKey]"
      :label="item[labelKey]"
      :value="parseInt(item[valueKey])">
    </el-option>
  </el-select>
</template>

<script>
export default {
  name: "customSelectorsDictionary",
  props:{
    options:{
      type:Array,
      default:()=>[]
    },
    value:[String , Number],
    labelKey:{
      type:String,
      default:'label'
    },
    valueKey:{
      type:String,
      default: 'value',
    },
  },
  data(){
    return{
      selectVal:''
    }
  },
  mounted() {
    this.selectVal = this.value;
  },
  watch:{
    selectVal(val){
      this.$emit('input',val)
    },
    value(val){
      this.selectVal = val;
    }
  }
}
</script>

<style scoped lang="scss">
</style>