Select.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <div class="wrap">
  3. <Select
  4. class="select"
  5. :mode="mode"
  6. :value="value"
  7. :options="options"
  8. @focus="onFocus"
  9. @change="onChange"
  10. @blur="onBlur"
  11. />
  12. <span>{{ reactData.tip }}</span>
  13. </div>
  14. </template>
  15. <script lang="ts">
  16. import { Select } from 'ant-design-vue';
  17. import { defineComponent, reactive, toRefs } from 'vue';
  18. const props = {
  19. value: { type: String, default: '' },
  20. tip: { type: String, default: '' },
  21. mode: { type: String, default: '' },
  22. options: { type: Array, default: [] },
  23. };
  24. export default defineComponent({
  25. components: { Select },
  26. props,
  27. emits: ['change'],
  28. setup(props, { emit }) {
  29. const reactData = reactive({
  30. tip: '',
  31. });
  32. function onFocus() {
  33. reactData.tip = props.tip;
  34. }
  35. function onBlur() {
  36. reactData.tip = '';
  37. }
  38. function onChange(val) {
  39. emit('change', val);
  40. }
  41. return {
  42. onFocus,
  43. onBlur,
  44. onChange,
  45. reactData,
  46. ...toRefs(props),
  47. };
  48. },
  49. });
  50. </script>
  51. <style scoped>
  52. .wrap {
  53. display: flex;
  54. }
  55. .select {
  56. width: 55%;
  57. margin-right: 10px;
  58. }
  59. span {
  60. font-size: 13px;
  61. line-height: 250%;
  62. color: gray;
  63. }
  64. </style>