Custom Action Buttons β
Demonstrates the usage of all slots, including scenarios for completely replacing the action button area, prepending content, appending content, and various other customization cases.
Custom Action Demo β
Slot Usage Instructions β
actions Slot β
Completely replace the default action button area for maximum customization flexibility:
<template #actions="{ searchLoading, resetLoading }">
<div class="custom-actions">
<el-button
type="primary"
:loading="searchLoading"
@click="handleCustomSearch"
>
Search Now
</el-button>
<el-button @click="handleAdvancedSearch">
Advanced Search
</el-button>
<el-button
:loading="resetLoading"
@click="handleCustomReset"
>
Clear Conditions
</el-button>
</div>
</template>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
beforeActions Slot β
Insert custom content before the default action buttons:
<template #beforeActions>
<el-button type="info" @click="handleImport">
Import Conditions
</el-button>
<el-button type="warning" @click="handleExport">
Export Conditions
</el-button>
</template>
2
3
4
5
6
7
8
afterActions Slot β
Append custom content after the default action buttons:
<template #afterActions>
<el-button type="success" @click="handleSaveTemplate">
Save Template
</el-button>
<el-dropdown @command="handleQuickAction">
<el-button>
Quick Actions <el-icon><arrow-down /></el-icon>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="clear">Clear All</el-dropdown-item>
<el-dropdown-item command="today">Today's Data</el-dropdown-item>
<el-dropdown-item command="week">This Week's Data</el-dropdown-item>
</el-dropdown-Menu>
</template>
</el-dropdown>
</template>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Usage Scenarios β
1. Search Template Management β
Add functionality to save and load search templates for easy reuse of common search conditions.
2. Data Import/Export β
Add import/export functionality to the search area to support batch operations and data exchange.
3. Quick Action Menu β
Provide dropdown menus for quick actions like filtering today's, this week's, or this month's data.
4. Multi-step Search Process β
Implement wizard-style search processes controlled by custom buttons.
Slot Parameter Description β
actions Slot Parameters β
searchLoading: boolean
- Search button loading stateresetLoading: boolean
- Reset button loading state
beforeActions & afterActions Slots β
- No parameters, pure content insertion
Key Features β
- π¨ Fully customizable action area
- π§ Flexible slot system design
- π¦ Extended capabilities while preserving original functionality
- οΏ½ Support for complex business scenario customization
- β‘ High-performance slot rendering mechanism
Design Patterns β
Replacement Mode (actions) β
Suitable for scenarios requiring complete redesign of the action area:
<!-- Fully customized action area -->
<template #actions>
<CustomActionBar />
</template>
2
3
4
Extension Mode (beforeActions/afterActions) β
Suitable for adding extra actions while maintaining default functionality:
<!-- Extend on default buttons -->
<template #beforeActions>
<ExtraActions />
</template>
2
3
4
Best Practices β
1. Maintain Operational Consistency β
Keep custom action buttons visually consistent with the overall system style.
2. Proper Use of Loading States β
Utilize the loading
state parameters in slots to add loading effects to custom buttons.
3. Responsive Design β
Ensure custom actions display and function properly across different screen sizes.
4. User Experience Optimization β
- Provide clear operation feedback
- Add appropriate confirmation dialogs
- Implement undo functionality for actions
Related Links β
- Method Demo - Learn about all exposed method usages
- Dynamic Management - Learn about dynamic search item management
- Form Validation - Learn about form validation features