index.vue 866 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <div class="capital-info">
  3. </div>
  4. </template>
  5. <script lang="ts">
  6. import { defineComponent, ref, PropType } from 'vue';
  7. interface Key {
  8. [propName: string]: string;
  9. }
  10. export default defineComponent({
  11. name: 'first-menu',
  12. props: {
  13. list: {
  14. default: [],
  15. type: Object as PropType<Key[]>,
  16. },
  17. value: {
  18. // 需要绑定的值得 key
  19. default: '',
  20. type: String,
  21. },
  22. },
  23. components: {},
  24. setup(props, context) {
  25. const current = ref<string[]>(['0']);
  26. function menuClick(value: any) {
  27. const index = +value.key;
  28. context.emit('selectMenu', props.list[index]);
  29. }
  30. return {
  31. current,
  32. menuClick,
  33. };
  34. },
  35. });
  36. </script>
  37. <style lang="less">
  38. .capital-info {
  39. }
  40. </style>;