DropDown.vue 1.5 KB
<template>
  <van-dropdown-menu active-color="#3369B1" class="qw-drop-down">
    <van-dropdown-item v-model="value1" :options="option1" @change="selectChange" />
    <van-dropdown-item v-model="value2" :disabled="disabled" :options="option2" @change="selectSecondChange" />
  </van-dropdown-menu>
</template>
<script>
export default {
  name: 'DropDown',
  data() {
    return {
      option1: this.selectOption1,
      option2: this.selectOption2,
      value1: this.currentValue1,
      value2: this.currentValue2,
      disabled: false
    }
  },
  watch: {
    currentValue1(n) {
      this.value1 = n
    },
    currentValue2(n) {
      this.value2 = n
    },
    selectOption2(n) {
      this.option2 = n
    }
  },
  props: {
    selectOption1: {
      type: Array,
      default: () => {
        return []
      }
    },
    selectOption2: {
      type: Array,
      default: () => {
        return []
      }
    },
    currentValue1: {
      type: Number,
      default: 0
    },
    currentValue2: {
      type: Number,
      default: 0
    }
  },
  methods: {
    selectChange(value) {
      this.disabled = false
      if (value == 2) this.disabled = true
      this.value1 = value
      this.$emit('changeFirst', value)
    },
    selectSecondChange(value) {
      this.value2 = value
      this.$emit('changeSecond', value)
    }
  }
}
</script>
<style lang="scss" scoped>
.qw-drop-down /deep/ .van-dropdown-menu__title {
  font-size: 14px !important;
  font-weight: 400 !important;
  color: #333333 !important;
}
</style>