grouping.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <el-select v-model="value" placeholder="Select">
  3. <el-option-group v-for="group in options" :key="group.label" :label="group.label">
  4. <el-option v-for="item in group.options" :key="item.value" :label="item.label" :value="item.value" />
  5. </el-option-group>
  6. </el-select>
  7. </template>
  8. <script lang="ts" setup>
  9. import { ref } from 'vue'
  10. const value = ref('')
  11. const options = [
  12. {
  13. label: 'Popular cities',
  14. options: [
  15. {
  16. value: 'Shanghai',
  17. label: 'Shanghai',
  18. },
  19. {
  20. value: 'Beijing',
  21. label: 'Beijing',
  22. },
  23. ],
  24. },
  25. {
  26. label: 'City name',
  27. options: [
  28. {
  29. value: 'Chengdu',
  30. label: 'Chengdu',
  31. },
  32. {
  33. value: 'Shenzhen',
  34. label: 'Shenzhen',
  35. },
  36. {
  37. value: 'Guangzhou',
  38. label: 'Guangzhou',
  39. },
  40. {
  41. value: 'Dalian',
  42. label: 'Dalian',
  43. },
  44. ],
  45. },
  46. ]
  47. </script>