c-button.vue 857 B

1234567891011121314151617181920212223242526
  1. <template>
  2. <div id="c-button" style="text-align: right">
  3. <el-button type="primary" @click="toAdd()" v-if="isAdd">新增</el-button>
  4. <el-button type="warning" v-if="isEdit">修改</el-button>
  5. <el-button type="danger" v-if="isDel">删除</el-button>
  6. <el-button type="warning" @click="toExport()" v-if="isExport">导出</el-button>
  7. <slot></slot>
  8. </div>
  9. </template>
  10. <script setup lang="ts">
  11. import { toRefs } from 'vue';
  12. const props = defineProps({
  13. isAdd: { type: Boolean, default: () => true },
  14. isEdit: { type: Boolean, default: () => false },
  15. isDel: { type: Boolean, default: () => false },
  16. isExport: { type: Boolean, default: () => false }
  17. });
  18. const { isAdd } = toRefs(props);
  19. const emit = defineEmits(['toAdd', 'toExport']);
  20. const toAdd = () => {
  21. emit('toAdd');
  22. };
  23. const toExport = () => {
  24. emit('toExport');
  25. };
  26. </script>