Are you an LLM? You can read better optimized documentation at /front/component/ma-pro-table/examples/basic.md for this page in Markdown format
Basic Usage β
The simplest way to use a table, including search, pagination, and basic operation functionality.
Key Features β
- Quick Setup: Built on the combination of ma-search and ma-table
- Search Functionality: Built-in search form supporting various search components
- Pagination Support: Automatic pagination logic handling
- Action Column: Flexible configuration for operation buttons
- Data Binding: Automatic API request handling and data rendering
Core Configuration β
Basic Structure β
vue
<template>
<MaProTable :options="options" :schema="schema" />
</template>
<script setup>
import { reactive } from 'vue'
// Component configuration
const options = reactive({
requestOptions: {
api: getDataList, // API endpoint
autoRequest: true, // Auto request
response: {
totalKey: 'data.total',
dataKey: 'data.list'
}
},
tableOptions: {
adaption: true, // Auto height adjustment
pagination: {
total: 0,
pageSize: 10
}
}
})
// Table schema
const schema = reactive({
searchItems: [ // Search configuration
{
label: 'Name',
prop: 'name',
render: 'input'
}
],
tableColumns: [ // Table column configuration
{ label: 'ID', prop: 'id' },
{ label: 'Name', prop: 'name' }
]
})
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Action Column Configuration β
javascript
{
type: 'operation',
label: 'Actions',
width: 200,
operationConfigure: {
type: 'tile', // Tile display
actions: [
{
name: 'edit',
text: 'Edit',
onClick: (data) => {
console.log('Edit', data.row)
}
}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Usage Instructions β
- API Interface: Should return data in the format
{ code, data: { list, total } }
- Search Components: Supports various types including input, select, date, etc.
- Action Buttons: Configurable click events, display conditions, styles, etc.
- Auto Height Adjustment: Enabling
adaption
will automatically calculate table height
This is the most basic example of using MaProTable, demonstrating how to quickly build a complete CRUD interface.