@templmf/temp-solf-lmf 0.0.27 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/code-reviewer/SKILL.md +482 -0
- package/skills/daily-qa-skill/SKILL.md +147 -0
- package/skills/daily-qa-skill/references/tools.md +130 -0
- package/skills/element-plus-vue3/LICENSE.txt +202 -0
- package/skills/element-plus-vue3/SKILL.md +218 -0
- package/skills/element-plus-vue3/api/component-api.md +94 -0
- package/skills/element-plus-vue3/api/global-config.md +89 -0
- package/skills/element-plus-vue3/api/props-and-events.md +101 -0
- package/skills/element-plus-vue3/examples/components/button.md +99 -0
- package/skills/element-plus-vue3/examples/components/date-picker.md +115 -0
- package/skills/element-plus-vue3/examples/components/dialog.md +106 -0
- package/skills/element-plus-vue3/examples/components/form.md +127 -0
- package/skills/element-plus-vue3/examples/components/input.md +123 -0
- package/skills/element-plus-vue3/examples/components/message.md +93 -0
- package/skills/element-plus-vue3/examples/components/overview.md +59 -0
- package/skills/element-plus-vue3/examples/components/select.md +133 -0
- package/skills/element-plus-vue3/examples/components/table.md +166 -0
- package/skills/element-plus-vue3/examples/guide/design.md +68 -0
- package/skills/element-plus-vue3/examples/guide/global-config.md +95 -0
- package/skills/element-plus-vue3/examples/guide/i18n.md +95 -0
- package/skills/element-plus-vue3/examples/guide/installation.md +110 -0
- package/skills/element-plus-vue3/examples/guide/quick-start.md +103 -0
- package/skills/element-plus-vue3/examples/guide/theme.md +78 -0
- package/skills/element-plus-vue3/templates/component-usage.md +92 -0
- package/skills/element-plus-vue3/templates/installation.md +82 -0
- package/skills/element-plus-vue3/templates/project-setup.md +83 -0
- package/test.md +7 -5
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Global Configuration
|
|
2
|
+
|
|
3
|
+
## API Reference
|
|
4
|
+
|
|
5
|
+
Element Plus global configuration options.
|
|
6
|
+
|
|
7
|
+
### Global Config Options
|
|
8
|
+
|
|
9
|
+
When using `app.use(ElementPlus, options)`, you can pass:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
interface ElementPlusOptions {
|
|
13
|
+
size?: 'large' | 'default' | 'small'
|
|
14
|
+
zIndex?: number
|
|
15
|
+
locale?: Locale
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### ConfigProvider Props
|
|
20
|
+
|
|
21
|
+
**Props:**
|
|
22
|
+
- `size` - Global size (large, default, small)
|
|
23
|
+
- `zIndex` - Global z-index (default: 3000)
|
|
24
|
+
- `locale` - Locale object
|
|
25
|
+
- `button` - Button config
|
|
26
|
+
- `message` - Message config
|
|
27
|
+
|
|
28
|
+
### Example: Global Config
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import { createApp } from 'vue'
|
|
32
|
+
import ElementPlus from 'element-plus'
|
|
33
|
+
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
|
34
|
+
|
|
35
|
+
const app = createApp(App)
|
|
36
|
+
app.use(ElementPlus, {
|
|
37
|
+
size: 'large',
|
|
38
|
+
zIndex: 3000,
|
|
39
|
+
locale: zhCn
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Example: ConfigProvider
|
|
44
|
+
|
|
45
|
+
```vue
|
|
46
|
+
<template>
|
|
47
|
+
<el-config-provider
|
|
48
|
+
:size="size"
|
|
49
|
+
:z-index="zIndex"
|
|
50
|
+
:locale="locale"
|
|
51
|
+
>
|
|
52
|
+
<el-button>Button</el-button>
|
|
53
|
+
</el-config-provider>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script setup>
|
|
57
|
+
import { ref } from 'vue'
|
|
58
|
+
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
|
59
|
+
|
|
60
|
+
const size = ref('default')
|
|
61
|
+
const zIndex = ref(3000)
|
|
62
|
+
const locale = ref(zhCn)
|
|
63
|
+
</script>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Size Configuration
|
|
67
|
+
|
|
68
|
+
**Options:**
|
|
69
|
+
- `'large'` - Large size
|
|
70
|
+
- `'default'` - Default size
|
|
71
|
+
- `'small'` - Small size
|
|
72
|
+
|
|
73
|
+
### z-index Configuration
|
|
74
|
+
|
|
75
|
+
**Default:** `3000`
|
|
76
|
+
|
|
77
|
+
Controls z-index for overlays (Dialog, Drawer, etc.).
|
|
78
|
+
|
|
79
|
+
### Locale Configuration
|
|
80
|
+
|
|
81
|
+
Import locale from `element-plus/dist/locale/`:
|
|
82
|
+
- `zh-cn.mjs` - Chinese (Simplified)
|
|
83
|
+
- `en.mjs` - English
|
|
84
|
+
- `es.mjs` - Spanish
|
|
85
|
+
- `fr.mjs` - French
|
|
86
|
+
- `ja.mjs` - Japanese
|
|
87
|
+
- `ko.mjs` - Korean
|
|
88
|
+
|
|
89
|
+
**See also:** `examples/guide/i18n.md` for i18n examples
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Props and Events
|
|
2
|
+
|
|
3
|
+
## API Reference
|
|
4
|
+
|
|
5
|
+
Common props and events in Element Plus components.
|
|
6
|
+
|
|
7
|
+
### Common Props
|
|
8
|
+
|
|
9
|
+
#### size
|
|
10
|
+
|
|
11
|
+
**Type:** `'large' | 'default' | 'small'`
|
|
12
|
+
|
|
13
|
+
Component size.
|
|
14
|
+
|
|
15
|
+
#### disabled
|
|
16
|
+
|
|
17
|
+
**Type:** `boolean`
|
|
18
|
+
|
|
19
|
+
**Default:** `false`
|
|
20
|
+
|
|
21
|
+
Whether component is disabled.
|
|
22
|
+
|
|
23
|
+
#### className
|
|
24
|
+
|
|
25
|
+
**Type:** `string`
|
|
26
|
+
|
|
27
|
+
Custom CSS class name.
|
|
28
|
+
|
|
29
|
+
#### style
|
|
30
|
+
|
|
31
|
+
**Type:** `string | object`
|
|
32
|
+
|
|
33
|
+
Custom inline style.
|
|
34
|
+
|
|
35
|
+
### Common Events
|
|
36
|
+
|
|
37
|
+
#### @click
|
|
38
|
+
|
|
39
|
+
**Type:** `Function`
|
|
40
|
+
|
|
41
|
+
Click event handler.
|
|
42
|
+
|
|
43
|
+
**Example:**
|
|
44
|
+
```vue
|
|
45
|
+
<el-button @click="handleClick">Button</el-button>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### @change
|
|
49
|
+
|
|
50
|
+
**Type:** `Function`
|
|
51
|
+
|
|
52
|
+
Change event handler.
|
|
53
|
+
|
|
54
|
+
**Example:**
|
|
55
|
+
```vue
|
|
56
|
+
<el-input v-model="value" @change="handleChange" />
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### @focus
|
|
60
|
+
|
|
61
|
+
**Type:** `Function`
|
|
62
|
+
|
|
63
|
+
Focus event handler.
|
|
64
|
+
|
|
65
|
+
**Example:**
|
|
66
|
+
```vue
|
|
67
|
+
<el-input @focus="handleFocus" />
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
#### @blur
|
|
71
|
+
|
|
72
|
+
**Type:** `Function`
|
|
73
|
+
|
|
74
|
+
Blur event handler.
|
|
75
|
+
|
|
76
|
+
**Example:**
|
|
77
|
+
```vue
|
|
78
|
+
<el-input @blur="handleBlur" />
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Event Object
|
|
82
|
+
|
|
83
|
+
Event handlers receive an event object:
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
handleEvent(event) {
|
|
87
|
+
// event.target - Target element
|
|
88
|
+
// event.currentTarget - Current target element
|
|
89
|
+
// event.detail - Event detail (component-specific)
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Component-Specific Events
|
|
94
|
+
|
|
95
|
+
Different components emit different events:
|
|
96
|
+
- **Input**: @input, @change, @focus, @blur
|
|
97
|
+
- **Select**: @change, @visible-change
|
|
98
|
+
- **Table**: @selection-change, @row-click, @sort-change
|
|
99
|
+
- **Form**: @validate
|
|
100
|
+
|
|
101
|
+
**See also:** `examples/components/` for component-specific examples
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Button Component
|
|
2
|
+
|
|
3
|
+
**官方文档**: https://element-plus.org/en-US/component/button.html
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Instructions
|
|
7
|
+
|
|
8
|
+
This example demonstrates the Button component in Element Plus.
|
|
9
|
+
|
|
10
|
+
### Key Concepts
|
|
11
|
+
|
|
12
|
+
- Button types
|
|
13
|
+
- Button sizes
|
|
14
|
+
- Button states
|
|
15
|
+
- Button groups
|
|
16
|
+
- Button events
|
|
17
|
+
|
|
18
|
+
### Example: Basic Button
|
|
19
|
+
|
|
20
|
+
```vue
|
|
21
|
+
<template>
|
|
22
|
+
<el-button>Default</el-button>
|
|
23
|
+
<el-button type="primary">Primary</el-button>
|
|
24
|
+
<el-button type="success">Success</el-button>
|
|
25
|
+
<el-button type="info">Info</el-button>
|
|
26
|
+
<el-button type="warning">Warning</el-button>
|
|
27
|
+
<el-button type="danger">Danger</el-button>
|
|
28
|
+
</template>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Example: Button Sizes
|
|
32
|
+
|
|
33
|
+
```vue
|
|
34
|
+
<template>
|
|
35
|
+
<el-button size="large">Large</el-button>
|
|
36
|
+
<el-button size="default">Default</el-button>
|
|
37
|
+
<el-button size="small">Small</el-button>
|
|
38
|
+
</template>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Example: Button States
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<template>
|
|
45
|
+
<el-button disabled>Disabled</el-button>
|
|
46
|
+
<el-button loading>Loading</el-button>
|
|
47
|
+
<el-button plain>Plain</el-button>
|
|
48
|
+
<el-button round>Round</el-button>
|
|
49
|
+
<el-button circle>Circle</el-button>
|
|
50
|
+
</template>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Example: Button Events
|
|
54
|
+
|
|
55
|
+
```vue
|
|
56
|
+
<template>
|
|
57
|
+
<el-button type="primary" @click="handleClick">
|
|
58
|
+
Click Me
|
|
59
|
+
</el-button>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup>
|
|
63
|
+
const handleClick = () => {
|
|
64
|
+
console.log('Button clicked')
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Example: Button Group
|
|
70
|
+
|
|
71
|
+
```vue
|
|
72
|
+
<template>
|
|
73
|
+
<el-button-group>
|
|
74
|
+
<el-button type="primary" icon="ArrowLeft">Previous</el-button>
|
|
75
|
+
<el-button type="primary" icon="ArrowRight">Next</el-button>
|
|
76
|
+
</el-button-group>
|
|
77
|
+
</template>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Example: Button with Icon
|
|
81
|
+
|
|
82
|
+
```vue
|
|
83
|
+
<template>
|
|
84
|
+
<el-button type="primary" icon="Search">Search</el-button>
|
|
85
|
+
<el-button type="primary" :icon="Search">Search</el-button>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<script setup>
|
|
89
|
+
import { Search } from '@element-plus/icons-vue'
|
|
90
|
+
</script>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Key Points
|
|
94
|
+
|
|
95
|
+
- Multiple types: primary, success, info, warning, danger
|
|
96
|
+
- Multiple sizes: large, default, small
|
|
97
|
+
- Support disabled, loading, plain, round, circle
|
|
98
|
+
- Icon support
|
|
99
|
+
- Button group support
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# DatePicker Component
|
|
2
|
+
|
|
3
|
+
**官方文档**: https://element-plus.org/en-US/component/date-picker.html
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Instructions
|
|
7
|
+
|
|
8
|
+
This example demonstrates the DatePicker component in Element Plus.
|
|
9
|
+
|
|
10
|
+
### Key Concepts
|
|
11
|
+
|
|
12
|
+
- Date selection
|
|
13
|
+
- Date range
|
|
14
|
+
- Date format
|
|
15
|
+
- Date picker types
|
|
16
|
+
|
|
17
|
+
### Example: Basic DatePicker
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<template>
|
|
21
|
+
<el-date-picker v-model="date" type="date" placeholder="Select date" />
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
import { ref } from 'vue'
|
|
26
|
+
|
|
27
|
+
const date = ref('')
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Example: Date Range
|
|
32
|
+
|
|
33
|
+
```vue
|
|
34
|
+
<template>
|
|
35
|
+
<el-date-picker
|
|
36
|
+
v-model="dateRange"
|
|
37
|
+
type="daterange"
|
|
38
|
+
range-separator="To"
|
|
39
|
+
start-placeholder="Start date"
|
|
40
|
+
end-placeholder="End date"
|
|
41
|
+
/>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup>
|
|
45
|
+
import { ref } from 'vue'
|
|
46
|
+
|
|
47
|
+
const dateRange = ref([])
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Example: Date Picker Types
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<template>
|
|
55
|
+
<el-date-picker v-model="date" type="date" />
|
|
56
|
+
<el-date-picker v-model="datetime" type="datetime" />
|
|
57
|
+
<el-date-picker v-model="daterange" type="daterange" />
|
|
58
|
+
<el-date-picker v-model="datetimerange" type="datetimerange" />
|
|
59
|
+
<el-date-picker v-model="month" type="month" />
|
|
60
|
+
<el-date-picker v-model="year" type="year" />
|
|
61
|
+
</template>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Example: Date Format
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<template>
|
|
68
|
+
<el-date-picker
|
|
69
|
+
v-model="date"
|
|
70
|
+
type="date"
|
|
71
|
+
format="YYYY-MM-DD"
|
|
72
|
+
value-format="YYYY-MM-DD"
|
|
73
|
+
/>
|
|
74
|
+
</template>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Example: Date Picker with Shortcuts
|
|
78
|
+
|
|
79
|
+
```vue
|
|
80
|
+
<template>
|
|
81
|
+
<el-date-picker
|
|
82
|
+
v-model="date"
|
|
83
|
+
type="date"
|
|
84
|
+
:shortcuts="shortcuts"
|
|
85
|
+
/>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<script setup>
|
|
89
|
+
import { ref } from 'vue'
|
|
90
|
+
|
|
91
|
+
const date = ref('')
|
|
92
|
+
const shortcuts = [
|
|
93
|
+
{
|
|
94
|
+
text: 'Today',
|
|
95
|
+
value: new Date()
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
text: 'Yesterday',
|
|
99
|
+
value: () => {
|
|
100
|
+
const date = new Date()
|
|
101
|
+
date.setTime(date.getTime() - 3600 * 1000 * 24)
|
|
102
|
+
return date
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
</script>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Key Points
|
|
110
|
+
|
|
111
|
+
- Use v-model for selected date
|
|
112
|
+
- Multiple types: date, datetime, daterange, etc.
|
|
113
|
+
- Configure format and value-format
|
|
114
|
+
- Support shortcuts
|
|
115
|
+
- Use Day.js for date handling
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Dialog Component
|
|
2
|
+
|
|
3
|
+
**官方文档**: https://element-plus.org/en-US/component/dialog.html
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Instructions
|
|
7
|
+
|
|
8
|
+
This example demonstrates the Dialog component in Element Plus.
|
|
9
|
+
|
|
10
|
+
### Key Concepts
|
|
11
|
+
|
|
12
|
+
- Dialog visibility
|
|
13
|
+
- Dialog content
|
|
14
|
+
- Dialog actions
|
|
15
|
+
- Dialog events
|
|
16
|
+
- Dialog methods
|
|
17
|
+
|
|
18
|
+
### Example: Basic Dialog
|
|
19
|
+
|
|
20
|
+
```vue
|
|
21
|
+
<template>
|
|
22
|
+
<el-button @click="dialogVisible = true">Open Dialog</el-button>
|
|
23
|
+
<el-dialog v-model="dialogVisible" title="Dialog Title">
|
|
24
|
+
<span>Dialog Content</span>
|
|
25
|
+
<template #footer>
|
|
26
|
+
<el-button @click="dialogVisible = false">Cancel</el-button>
|
|
27
|
+
<el-button type="primary" @click="dialogVisible = false">Confirm</el-button>
|
|
28
|
+
</template>
|
|
29
|
+
</el-dialog>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script setup>
|
|
33
|
+
import { ref } from 'vue'
|
|
34
|
+
|
|
35
|
+
const dialogVisible = ref(false)
|
|
36
|
+
</script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Example: Dialog with Form
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<template>
|
|
43
|
+
<el-button @click="dialogVisible = true">Open Dialog</el-button>
|
|
44
|
+
<el-dialog v-model="dialogVisible" title="Form Dialog" width="500px">
|
|
45
|
+
<el-form :model="form" label-width="100px">
|
|
46
|
+
<el-form-item label="Name">
|
|
47
|
+
<el-input v-model="form.name" />
|
|
48
|
+
</el-form-item>
|
|
49
|
+
<el-form-item label="Email">
|
|
50
|
+
<el-input v-model="form.email" />
|
|
51
|
+
</el-form-item>
|
|
52
|
+
</el-form>
|
|
53
|
+
<template #footer>
|
|
54
|
+
<el-button @click="dialogVisible = false">Cancel</el-button>
|
|
55
|
+
<el-button type="primary" @click="handleSubmit">Submit</el-button>
|
|
56
|
+
</template>
|
|
57
|
+
</el-dialog>
|
|
58
|
+
</template>
|
|
59
|
+
|
|
60
|
+
<script setup>
|
|
61
|
+
import { ref } from 'vue'
|
|
62
|
+
|
|
63
|
+
const dialogVisible = ref(false)
|
|
64
|
+
const form = ref({
|
|
65
|
+
name: '',
|
|
66
|
+
email: ''
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const handleSubmit = () => {
|
|
70
|
+
console.log('Form:', form.value)
|
|
71
|
+
dialogVisible.value = false
|
|
72
|
+
}
|
|
73
|
+
</script>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Example: Dialog Methods
|
|
77
|
+
|
|
78
|
+
```vue
|
|
79
|
+
<template>
|
|
80
|
+
<el-button @click="openDialog">Open Dialog</el-button>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<script setup>
|
|
84
|
+
import { ElMessageBox } from 'element-plus'
|
|
85
|
+
|
|
86
|
+
const openDialog = () => {
|
|
87
|
+
ElMessageBox.confirm('Are you sure?', 'Confirm', {
|
|
88
|
+
confirmButtonText: 'OK',
|
|
89
|
+
cancelButtonText: 'Cancel',
|
|
90
|
+
type: 'warning'
|
|
91
|
+
}).then(() => {
|
|
92
|
+
console.log('Confirmed')
|
|
93
|
+
}).catch(() => {
|
|
94
|
+
console.log('Cancelled')
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Key Points
|
|
101
|
+
|
|
102
|
+
- Control visibility with v-model
|
|
103
|
+
- Use title prop for dialog title
|
|
104
|
+
- Customize footer with footer slot
|
|
105
|
+
- Support form inside dialog
|
|
106
|
+
- Use ElMessageBox for programmatic dialogs
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Form Component
|
|
2
|
+
|
|
3
|
+
**官方文档**: https://element-plus.org/en-US/component/form.html
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Instructions
|
|
7
|
+
|
|
8
|
+
This example demonstrates the Form component in Element Plus.
|
|
9
|
+
|
|
10
|
+
### Key Concepts
|
|
11
|
+
|
|
12
|
+
- Form structure
|
|
13
|
+
- Form validation
|
|
14
|
+
- Form rules
|
|
15
|
+
- Form submission
|
|
16
|
+
- Form fields
|
|
17
|
+
|
|
18
|
+
### Example: Basic Form
|
|
19
|
+
|
|
20
|
+
```vue
|
|
21
|
+
<template>
|
|
22
|
+
<el-form :model="form" label-width="120px">
|
|
23
|
+
<el-form-item label="Name">
|
|
24
|
+
<el-input v-model="form.name" />
|
|
25
|
+
</el-form-item>
|
|
26
|
+
<el-form-item label="Email">
|
|
27
|
+
<el-input v-model="form.email" />
|
|
28
|
+
</el-form-item>
|
|
29
|
+
<el-form-item>
|
|
30
|
+
<el-button type="primary" @click="handleSubmit">Submit</el-button>
|
|
31
|
+
</el-form-item>
|
|
32
|
+
</el-form>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
36
|
+
import { ref } from 'vue'
|
|
37
|
+
|
|
38
|
+
const form = ref({
|
|
39
|
+
name: '',
|
|
40
|
+
email: ''
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const handleSubmit = () => {
|
|
44
|
+
console.log('Form:', form.value)
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Example: Form Validation
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<template>
|
|
53
|
+
<el-form
|
|
54
|
+
ref="formRef"
|
|
55
|
+
:model="form"
|
|
56
|
+
:rules="rules"
|
|
57
|
+
label-width="120px"
|
|
58
|
+
>
|
|
59
|
+
<el-form-item label="Name" prop="name">
|
|
60
|
+
<el-input v-model="form.name" />
|
|
61
|
+
</el-form-item>
|
|
62
|
+
<el-form-item label="Email" prop="email">
|
|
63
|
+
<el-input v-model="form.email" />
|
|
64
|
+
</el-form-item>
|
|
65
|
+
<el-form-item>
|
|
66
|
+
<el-button type="primary" @click="handleSubmit">Submit</el-button>
|
|
67
|
+
</el-form-item>
|
|
68
|
+
</el-form>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script setup>
|
|
72
|
+
import { ref } from 'vue'
|
|
73
|
+
|
|
74
|
+
const formRef = ref()
|
|
75
|
+
const form = ref({
|
|
76
|
+
name: '',
|
|
77
|
+
email: ''
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
const rules = {
|
|
81
|
+
name: [
|
|
82
|
+
{ required: true, message: 'Please input name', trigger: 'blur' }
|
|
83
|
+
],
|
|
84
|
+
email: [
|
|
85
|
+
{ required: true, message: 'Please input email', trigger: 'blur' },
|
|
86
|
+
{ type: 'email', message: 'Please input valid email', trigger: 'blur' }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const handleSubmit = async () => {
|
|
91
|
+
await formRef.value.validate((valid) => {
|
|
92
|
+
if (valid) {
|
|
93
|
+
console.log('Form valid:', form.value)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Example: Form Layout
|
|
101
|
+
|
|
102
|
+
```vue
|
|
103
|
+
<template>
|
|
104
|
+
<el-form :model="form" label-position="top">
|
|
105
|
+
<el-row :gutter="20">
|
|
106
|
+
<el-col :span="12">
|
|
107
|
+
<el-form-item label="Name">
|
|
108
|
+
<el-input v-model="form.name" />
|
|
109
|
+
</el-form-item>
|
|
110
|
+
</el-col>
|
|
111
|
+
<el-col :span="12">
|
|
112
|
+
<el-form-item label="Email">
|
|
113
|
+
<el-input v-model="form.email" />
|
|
114
|
+
</el-form-item>
|
|
115
|
+
</el-col>
|
|
116
|
+
</el-row>
|
|
117
|
+
</el-form>
|
|
118
|
+
</template>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Key Points
|
|
122
|
+
|
|
123
|
+
- Use :model for form data
|
|
124
|
+
- Configure :rules for validation
|
|
125
|
+
- Use prop for form-item validation
|
|
126
|
+
- Handle form submission
|
|
127
|
+
- Support multiple layouts
|