-
Notifications
You must be signed in to change notification settings - Fork 0
/
form-fields.ts
40 lines (32 loc) · 1.12 KB
/
form-fields.ts
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
import { useFormItem } from 'element-plus'
import { WeEditorFormFields } from 'wangeditor5-for-vue3'
export default function weFormFields() {
const formFileds: WeEditorFormFields = {}
const { formItem } = useFormItem()
if (formItem && typeof formItem.validate == 'function') {
formFileds.blurField = () => {
formItem.validate('blur')
}
formFileds.changeField = () => {
formItem.validate('change')
}
}
return formFileds
}
// 如果上面这一套无法正常运行,请使用下面这一套。下面这一套为 ElementPlus 旧版本的使用方式。
// import { inject } from 'vue'
// import { elFormItemKey } from 'element-plus'
// import { WeEditorFormFields } from 'wangeditor5-for-vue3'
// export default function weFormFields() {
// const elFormItem = inject(elFormItemKey)
// const formFileds: WeEditorFormFields = {}
// if (elFormItem && typeof elFormItem.validate === 'function') {
// formFileds.blurField = () => {
// elFormItem.validate('blur')
// }
// formFileds.changeField = () => {
// elFormItem.validate('change')
// }
// }
// return formFileds
// }