index.vue 884 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <template>
  2. <div class="btn-list">
  3. <a-button :class="item.className"
  4. v-for="item in btnList"
  5. :key="item.lable"
  6. @click.stop="onClick(item.callback)">
  7. {{item.lable}}
  8. </a-button>
  9. </div>
  10. </template>
  11. <script lang="ts">
  12. import { defineComponent, PropType } from 'vue';
  13. import { BtnList } from './interface';
  14. export default defineComponent({
  15. props: {
  16. btnList: {
  17. default: [],
  18. type: Array as PropType<BtnList[]>,
  19. },
  20. selectedData: {
  21. default: {},
  22. type: Object,
  23. },
  24. },
  25. setup(props, context) {
  26. function onClick(fn: Function) {
  27. context.emit('onClick', props.selectedData);
  28. fn && fn();
  29. }
  30. return { onClick };
  31. },
  32. });
  33. </script>
  34. <style lang="less">
  35. .btn-list {
  36. display: inline-flex;
  37. }
  38. </style>