el-form-renderer-vue3 1.0.0
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/.vite/deps_temp_ce3ed5bf/package.json +3 -0
- package/.vscode/extensions.json +3 -0
- package/LICENSE +661 -0
- package/README.en.md +36 -0
- package/README.md +252 -0
- package/index.html +13 -0
- package/package.json +34 -0
- package/public/vite.svg +1 -0
- package/src/App.vue +59 -0
- package/src/ChildCom.vue +24 -0
- package/src/assets/vue.svg +1 -0
- package/src/components/femessage/components/render-form-group.vue +48 -0
- package/src/components/femessage/components/render-form-item.vue +328 -0
- package/src/components/femessage/el-form-renderer.vue +284 -0
- package/src/components/femessage/util/CustomComponent.js +28 -0
- package/src/components/femessage/util/VNode.js +9 -0
- package/src/components/femessage/util/enable-when.js +26 -0
- package/src/components/femessage/util/transform-content.js +48 -0
- package/src/components/femessage/util/utils.js +127 -0
- package/src/el-form-renderer.md +220 -0
- package/src/main.js +15 -0
- package/src/router/index.js +160 -0
- package/src/style.css +89 -0
- package/src/view/AboutView.vue +40 -0
- package/src/view/HomeView.vue +134 -0
- package/src/view/MyInput.vue +46 -0
- package/src/view/checkboxGroup.vue +29 -0
- package/src/view/content.vue +176 -0
- package/src/view/deprecated.vue +37 -0
- package/src/view/disabled.vue +104 -0
- package/src/view/el.vue +24 -0
- package/src/view/format.vue +63 -0
- package/src/view/getcomponent.vue +51 -0
- package/src/view/getform.vue +50 -0
- package/src/view/hidden.vue +51 -0
- package/src/view/label.vue +25 -0
- package/src/view/next.vue +55 -0
- package/src/view/picker.vue +27 -0
- package/src/view/radioGroup.vue +38 -0
- package/src/view/readonly.vue +144 -0
- package/src/view/remote.vue +115 -0
- package/src/view/rules.vue +46 -0
- package/src/view/rulesPlus.vue +34 -0
- package/src/view/setoptios.vue +50 -0
- package/src/view/slot.vue +37 -0
- package/src/view/testAttrs.vue +17 -0
- package/src/view/update.vue +64 -0
- package/src/view/vmodel.vue +137 -0
- package/src/your-component.vue +55 -0
- package/vite.config.js +7 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-form-renderer inline :content="content" ref="form">
|
|
3
|
+
<el-form-item>
|
|
4
|
+
<el-button type="primary" @click="printValue">print</el-button>
|
|
5
|
+
<el-button @click="data = {}">reset</el-button>
|
|
6
|
+
</el-form-item>
|
|
7
|
+
</el-form-renderer>
|
|
8
|
+
<div>{{ data }}</div>
|
|
9
|
+
</template>
|
|
10
|
+
<script setup>
|
|
11
|
+
import { reactive, ref } from "vue";
|
|
12
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
13
|
+
const data = ref({})
|
|
14
|
+
const form = ref()
|
|
15
|
+
const content = reactive([
|
|
16
|
+
{
|
|
17
|
+
id: 'name',
|
|
18
|
+
type: 'input',
|
|
19
|
+
label: 'name',
|
|
20
|
+
default: 'alvin',
|
|
21
|
+
el: {
|
|
22
|
+
placeholder: 'input sth'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'area',
|
|
27
|
+
type: 'select',
|
|
28
|
+
label: 'select',
|
|
29
|
+
el: {
|
|
30
|
+
placeholder: 'select stn'
|
|
31
|
+
},
|
|
32
|
+
options: [{
|
|
33
|
+
label: 'shanghai',
|
|
34
|
+
value: 'shanghai'
|
|
35
|
+
}, {
|
|
36
|
+
label: 'beijing',
|
|
37
|
+
value: 'beijing'
|
|
38
|
+
}]
|
|
39
|
+
}
|
|
40
|
+
]);
|
|
41
|
+
const printValue = () => {
|
|
42
|
+
data.value = form.value.getFormValue()
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
<style scoped>
|
|
46
|
+
.box {
|
|
47
|
+
margin: 20px 0;
|
|
48
|
+
font-size: 20px;
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="box">hidden</div>
|
|
3
|
+
<div>动态隐藏表单项</div>
|
|
4
|
+
<el-form-renderer ref="form" :content="content" />
|
|
5
|
+
</template>
|
|
6
|
+
<script setup>
|
|
7
|
+
import { reactive, } from "vue";
|
|
8
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
9
|
+
|
|
10
|
+
const content = reactive([
|
|
11
|
+
{
|
|
12
|
+
type: 'select',
|
|
13
|
+
id: 'hobby',
|
|
14
|
+
label: 'hobby',
|
|
15
|
+
options: [
|
|
16
|
+
{
|
|
17
|
+
label: 'football',
|
|
18
|
+
value: 'football'
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: 'basketball',
|
|
22
|
+
value: 'basketball'
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: 'reason',
|
|
28
|
+
type: 'input',
|
|
29
|
+
id: 'reason',
|
|
30
|
+
el: {
|
|
31
|
+
placeholder: 'why'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: 'idol',
|
|
36
|
+
type: 'input',
|
|
37
|
+
id: 'idol',
|
|
38
|
+
el: {
|
|
39
|
+
placeholder: 'your idol?'
|
|
40
|
+
},
|
|
41
|
+
hidden: form => form.hobby !== 'basketball'
|
|
42
|
+
},
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
</script>
|
|
46
|
+
<style scoped>
|
|
47
|
+
.box {
|
|
48
|
+
margin: 20px 0;
|
|
49
|
+
font-size: 20px;
|
|
50
|
+
}
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="box">slot-label</div>
|
|
3
|
+
<el-form-renderer label-width="100px" :content="content" inline />
|
|
4
|
+
</template>
|
|
5
|
+
<script setup>
|
|
6
|
+
import { reactive, h, resolveComponent } from "vue";
|
|
7
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
8
|
+
const content = reactive([
|
|
9
|
+
{
|
|
10
|
+
type: 'input',
|
|
11
|
+
id: 'name',
|
|
12
|
+
label: h('span', {}, '输入'),
|
|
13
|
+
el: {
|
|
14
|
+
size: 'small',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
]);
|
|
19
|
+
</script>
|
|
20
|
+
<style scoped>
|
|
21
|
+
.box {
|
|
22
|
+
margin: 20px 0;
|
|
23
|
+
font-size: 20px;
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="box">next</div>
|
|
3
|
+
|
|
4
|
+
<el-button type="primary" @click="openDialogWithData">点击打开 Dialog(带数据)</el-button>
|
|
5
|
+
<el-button type="primary" @click="dialogVisible = true">点击打开 Dialog</el-button>
|
|
6
|
+
|
|
7
|
+
<el-dialog v-model="dialogVisible" title="Next Tick" @open="handleOpen" ref="dialog" @close="onClose">
|
|
8
|
+
<el-form-renderer :content="content" inline ref="formRender" />
|
|
9
|
+
</el-dialog>
|
|
10
|
+
</template>
|
|
11
|
+
<script setup>
|
|
12
|
+
import { reactive, ref, nextTick } from "vue";
|
|
13
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
14
|
+
let dialogVisible = ref(false)
|
|
15
|
+
const dialog = ref()
|
|
16
|
+
const formRender = ref()
|
|
17
|
+
const content = reactive(
|
|
18
|
+
[
|
|
19
|
+
{
|
|
20
|
+
id: 'name',
|
|
21
|
+
type: 'input',
|
|
22
|
+
label: '姓名',
|
|
23
|
+
el: {
|
|
24
|
+
placeholder: '请输入'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
]);
|
|
28
|
+
const handleOpen = async () => {
|
|
29
|
+
|
|
30
|
+
console.log(formRender.value)
|
|
31
|
+
formRender.value.updateForm({
|
|
32
|
+
name: '小明'
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
const openDialogWithData = async () => {
|
|
37
|
+
// Dialog 的内容是懒渲染的,即在第一次被打开之前,
|
|
38
|
+
//传入的默认 slot 不会被渲染到 DOM 上,所以需要使用 nextTick 等待 DOM 更新之后才能调用方法
|
|
39
|
+
dialogVisible.value = true
|
|
40
|
+
await nextTick()
|
|
41
|
+
formRender.value.updateForm({
|
|
42
|
+
name: '小明'
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
const onClose = () => {
|
|
46
|
+
formRender.value.resetFields()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
</script>
|
|
50
|
+
<style scoped>
|
|
51
|
+
.box {
|
|
52
|
+
margin: 20px 0;
|
|
53
|
+
font-size: 20px;
|
|
54
|
+
}
|
|
55
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="box">date-picker</div>
|
|
3
|
+
<el-form-renderer :content="content" inline />
|
|
4
|
+
</template>
|
|
5
|
+
<script setup>
|
|
6
|
+
import { reactive, } from "vue";
|
|
7
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
8
|
+
|
|
9
|
+
const content = reactive([
|
|
10
|
+
{
|
|
11
|
+
id: 'date',
|
|
12
|
+
type: 'date-picker',
|
|
13
|
+
label: 'date',
|
|
14
|
+
el: {
|
|
15
|
+
// type: 'daterange', // 如果 type 为 daterange,则获取到的是一个数组
|
|
16
|
+
valueFormat: 'timestamp' // 不使用 value-format 属性,则获取到的是一个空对象,格式请参考 element-ui 组件 date-picker 的日期格式部分
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
</script>
|
|
22
|
+
<style scoped>
|
|
23
|
+
.box {
|
|
24
|
+
margin: 20px 0;
|
|
25
|
+
font-size: 20px;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="box">radio-group</div>
|
|
3
|
+
|
|
4
|
+
<el-form-renderer label-width="100px" :content="content" ref="ruleForm">
|
|
5
|
+
</el-form-renderer>
|
|
6
|
+
</template>
|
|
7
|
+
<script setup>
|
|
8
|
+
import { reactive } from "vue";
|
|
9
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
10
|
+
const content = reactive([
|
|
11
|
+
{
|
|
12
|
+
id: 'city',
|
|
13
|
+
type: 'radio-group',
|
|
14
|
+
label: 'city',
|
|
15
|
+
/**
|
|
16
|
+
* sytle 属性是为了满足 el-radio-button属性而设置,如果不需要使用el-radio-button这可不设置
|
|
17
|
+
*/
|
|
18
|
+
style: 'button',
|
|
19
|
+
default: 'new york',
|
|
20
|
+
options: [
|
|
21
|
+
/**
|
|
22
|
+
* el-radio 用 label 来做 v-model 的值
|
|
23
|
+
* 这里会渲染成 <el-radio label="new york">new york</el-radio>
|
|
24
|
+
*/
|
|
25
|
+
{ label: 'new york' },
|
|
26
|
+
// 这里会渲染成 <el-radio label="a">guangzhou</el-radio>
|
|
27
|
+
{ label: 'guangzhou', value: 'a' },
|
|
28
|
+
{ label: 'tokyo' },
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
]);
|
|
32
|
+
</script>
|
|
33
|
+
<style scoped>
|
|
34
|
+
.box {
|
|
35
|
+
margin: 20px 0;
|
|
36
|
+
font-size: 20px;
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="box">readonly</div>
|
|
3
|
+
<div>设置 readonly 属性后,el-input 直接展示纯文本的值(value);el-select 显示对应的 label;其他组件等同于 disabled = true</div>
|
|
4
|
+
<el-form-renderer readonly label-width="100px" :content="content" ref="ruleForm">
|
|
5
|
+
<el-form-item>
|
|
6
|
+
<el-button type="primary" @click="submitForm('ruleForm')">submit</el-button>
|
|
7
|
+
<el-button @click="resetForm('ruleForm')">reset</el-button>
|
|
8
|
+
</el-form-item>
|
|
9
|
+
</el-form-renderer>
|
|
10
|
+
</template>
|
|
11
|
+
<script setup>
|
|
12
|
+
import { reactive, ref } from "vue";
|
|
13
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
14
|
+
const ruleForm = ref()
|
|
15
|
+
const content = reactive([
|
|
16
|
+
{
|
|
17
|
+
default: '小明',
|
|
18
|
+
type: 'input',
|
|
19
|
+
id: 'name',
|
|
20
|
+
label: 'name',
|
|
21
|
+
attrs: { 'data-name': 'form1' },
|
|
22
|
+
el: {
|
|
23
|
+
size: 'default',
|
|
24
|
+
placeholder: 'test placeholder'
|
|
25
|
+
},
|
|
26
|
+
rules: [
|
|
27
|
+
{ required: true, message: 'miss name', trigger: 'blur' },
|
|
28
|
+
{ min: 3, max: 5, message: 'length between 3 to 5', trigger: 'blur' }
|
|
29
|
+
]
|
|
30
|
+
}, {
|
|
31
|
+
default: 'shanghai',
|
|
32
|
+
type: 'select',
|
|
33
|
+
id: 'region',
|
|
34
|
+
label: 'area',
|
|
35
|
+
options: [{
|
|
36
|
+
label: '上海',
|
|
37
|
+
value: 'shanghai'
|
|
38
|
+
}, {
|
|
39
|
+
label: '北京',
|
|
40
|
+
value: 'beijing'
|
|
41
|
+
}],
|
|
42
|
+
rules: [
|
|
43
|
+
{ required: true, message: 'miss area', trigger: 'change' }
|
|
44
|
+
]
|
|
45
|
+
}, {
|
|
46
|
+
default: ['shanghai', 'beijing'],
|
|
47
|
+
type: 'select',
|
|
48
|
+
id: 'multi-region',
|
|
49
|
+
label: 'multi area',
|
|
50
|
+
options: [{
|
|
51
|
+
label: '上海',
|
|
52
|
+
value: 'shanghai'
|
|
53
|
+
}, {
|
|
54
|
+
label: '北京',
|
|
55
|
+
value: 'beijing'
|
|
56
|
+
}],
|
|
57
|
+
el: {
|
|
58
|
+
multiple: true
|
|
59
|
+
},
|
|
60
|
+
rules: [
|
|
61
|
+
{ required: true, message: 'miss area', trigger: 'change' }
|
|
62
|
+
]
|
|
63
|
+
}, {
|
|
64
|
+
default: '[native Date Wed Jan 01 2020 00:00:00 GMT+0800 (中国标准时间)]',
|
|
65
|
+
type: 'date-picker',
|
|
66
|
+
id: 'date',
|
|
67
|
+
label: 'date',
|
|
68
|
+
el: {
|
|
69
|
+
type: 'datetime',
|
|
70
|
+
placeholder: 'select date'
|
|
71
|
+
},
|
|
72
|
+
rules: [
|
|
73
|
+
{ type: 'date', required: true, message: 'miss date', trigger: 'change' }
|
|
74
|
+
]
|
|
75
|
+
}, {
|
|
76
|
+
default: true,
|
|
77
|
+
type: 'switch',
|
|
78
|
+
id: 'delivery',
|
|
79
|
+
label: 'delivery'
|
|
80
|
+
}, {
|
|
81
|
+
type: 'checkbox-group',
|
|
82
|
+
id: 'type',
|
|
83
|
+
label: 'type',
|
|
84
|
+
default: ['typeA', 'typeB'],
|
|
85
|
+
options: [{
|
|
86
|
+
label: 'typeA'
|
|
87
|
+
}, {
|
|
88
|
+
label: 'typeB'
|
|
89
|
+
}, {
|
|
90
|
+
label: 'typeC'
|
|
91
|
+
}],
|
|
92
|
+
rules: [
|
|
93
|
+
{ type: 'array', required: true, message: 'miss type', trigger: 'change' }
|
|
94
|
+
]
|
|
95
|
+
}, {
|
|
96
|
+
default: 'resourceA',
|
|
97
|
+
type: 'radio-group',
|
|
98
|
+
id: 'resource',
|
|
99
|
+
label: 'resource',
|
|
100
|
+
options: [{
|
|
101
|
+
label: 'resourceA'
|
|
102
|
+
}, {
|
|
103
|
+
label: 'resourceB'
|
|
104
|
+
}],
|
|
105
|
+
rules: [
|
|
106
|
+
{ required: true, message: 'miss resource', trigger: 'change' }
|
|
107
|
+
]
|
|
108
|
+
}, {
|
|
109
|
+
default: '小明的一些描述小明的一些描述小明的一些描述小明的一些描述小明的一些描述小明的一些描述小明的一些描述',
|
|
110
|
+
type: 'input',
|
|
111
|
+
id: 'desc',
|
|
112
|
+
label: 'desc',
|
|
113
|
+
el: {
|
|
114
|
+
type: 'textarea'
|
|
115
|
+
},
|
|
116
|
+
rules: [
|
|
117
|
+
{ required: true, message: 'miss desc', trigger: 'blur' }
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
]);
|
|
121
|
+
const submitForm = () => {
|
|
122
|
+
try {
|
|
123
|
+
ruleForm.value.methods.validate((valid) => {
|
|
124
|
+
if (valid) {
|
|
125
|
+
console.log("OK");
|
|
126
|
+
} else {
|
|
127
|
+
console.log("error submit!!");
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.log(error);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const resetForm = () => {
|
|
136
|
+
ruleForm.value.methods.resetFields();
|
|
137
|
+
};
|
|
138
|
+
</script>
|
|
139
|
+
<style scoped>
|
|
140
|
+
.box {
|
|
141
|
+
margin: 20px 0;
|
|
142
|
+
font-size: 20px;
|
|
143
|
+
}
|
|
144
|
+
</style>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-form-renderer :content="content" inline />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import { reactive, } from "vue";
|
|
7
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
8
|
+
|
|
9
|
+
let getRemoteUrl = (query) => 'https://mockapi.eolinker.com/IeZWjzy87c204a1f7030b2a17b00f3776ce0a07a5030a1b/el-form-renderer?q=remote&input=' + query
|
|
10
|
+
|
|
11
|
+
const content = reactive(
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
type: 'select',
|
|
15
|
+
id: 'select',
|
|
16
|
+
label: 'remote-by-url',
|
|
17
|
+
remote: {
|
|
18
|
+
url: '' // 通过设置 url,获取远程配置 options
|
|
19
|
+
},
|
|
20
|
+
el: {
|
|
21
|
+
placeholder: '请输入会发请求,',
|
|
22
|
+
filterable: true,
|
|
23
|
+
remote: true,
|
|
24
|
+
remoteMethod: query => {
|
|
25
|
+
content[0].remote.url = getRemoteUrl(query)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'select',
|
|
31
|
+
id: 'remote-by-request',
|
|
32
|
+
label: 'remote-by-request',
|
|
33
|
+
remote: {
|
|
34
|
+
// filterable 与 remote 为 true 时,会传入 query 参数
|
|
35
|
+
request(query) {
|
|
36
|
+
console.log(query)
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
el: {
|
|
40
|
+
width: '200px',
|
|
41
|
+
placeholder: '请输入,控制台会打印输入值',
|
|
42
|
+
filterable: true,
|
|
43
|
+
remote: true,
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// 可以自定义 request 方法,做各种操作
|
|
48
|
+
{
|
|
49
|
+
type: 'radio-group',
|
|
50
|
+
id: 'radio',
|
|
51
|
+
label: 'radio',
|
|
52
|
+
remote: {
|
|
53
|
+
url: 'fake.url', // 同时存在 url 与 request, 以后者为准
|
|
54
|
+
request() {
|
|
55
|
+
const resp = {
|
|
56
|
+
path: [
|
|
57
|
+
{ title: 'resourceA', name: 1 },
|
|
58
|
+
{ title: 'resourceB', name: 2 },
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
return new Promise(r => setTimeout(() => r(resp), 2000))
|
|
62
|
+
},
|
|
63
|
+
dataPath: 'path',
|
|
64
|
+
label: 'title',
|
|
65
|
+
value: 'name'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
// request 报错时也可以处理
|
|
69
|
+
{
|
|
70
|
+
type: 'checkbox-group',
|
|
71
|
+
id: 'checkbox',
|
|
72
|
+
label: 'checkbox',
|
|
73
|
+
default: [],
|
|
74
|
+
remote: {
|
|
75
|
+
request() {
|
|
76
|
+
// throw new Error('test')
|
|
77
|
+
return Promise.reject(new Error('test2'))
|
|
78
|
+
},
|
|
79
|
+
onError: error => {
|
|
80
|
+
console.warn(error.message)
|
|
81
|
+
return [
|
|
82
|
+
{ label: 'typeA' },
|
|
83
|
+
{ label: 'typeB' },
|
|
84
|
+
{ label: 'typeC' },
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
// 你想远程配置任何 prop 都行!
|
|
90
|
+
{
|
|
91
|
+
type: 'cascader',
|
|
92
|
+
id: 'cascader',
|
|
93
|
+
label: 'cascader',
|
|
94
|
+
default: [],
|
|
95
|
+
remote: {
|
|
96
|
+
prop: 'options',
|
|
97
|
+
request() {
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
100
|
+
label: 'hello',
|
|
101
|
+
value: 'hello',
|
|
102
|
+
children: [
|
|
103
|
+
{
|
|
104
|
+
label: 'world',
|
|
105
|
+
value: 'world',
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
</script>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-form-renderer :content="content" :rules="rules" />
|
|
3
|
+
</template>
|
|
4
|
+
<script setup>
|
|
5
|
+
import { reactive } from "vue";
|
|
6
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
7
|
+
let rule = [
|
|
8
|
+
{ required: true, message: 'using form rules', trigger: 'change' },
|
|
9
|
+
{ min: 3, max: 5, message: '3 <= length <= 5', trigger: 'change' }
|
|
10
|
+
]
|
|
11
|
+
const rules = reactive({ desc: [...rule] })
|
|
12
|
+
const content = reactive([
|
|
13
|
+
{
|
|
14
|
+
id: 'name',
|
|
15
|
+
type: 'input',
|
|
16
|
+
label: 'name',
|
|
17
|
+
el: {
|
|
18
|
+
placeholder: 'name'
|
|
19
|
+
},
|
|
20
|
+
rules: [
|
|
21
|
+
{
|
|
22
|
+
required: true,
|
|
23
|
+
message: 'using form-item rules',
|
|
24
|
+
trigger: 'change'
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: "input",
|
|
30
|
+
id: "desc",
|
|
31
|
+
label: "desc",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "input",
|
|
35
|
+
id: "money",
|
|
36
|
+
label: "money",
|
|
37
|
+
rules: [{ required: true, validator: (rule, value, callback) => value >= 0.01 ? callback() : callback(new Error('最小充值金额为0.01元')) }],
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
</script>
|
|
41
|
+
<style scoped>
|
|
42
|
+
.box {
|
|
43
|
+
margin: 20px 0;
|
|
44
|
+
font-size: 20px;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-form-renderer label-width="100px" :content="content" ref="form" :rules="rules">
|
|
3
|
+
</el-form-renderer>
|
|
4
|
+
</template>
|
|
5
|
+
<script setup>
|
|
6
|
+
import { reactive } from "vue";
|
|
7
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
8
|
+
const rule = [
|
|
9
|
+
{ required: true, message: '请输入活动名称', trigger: 'change' },
|
|
10
|
+
{ min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'change' }
|
|
11
|
+
];
|
|
12
|
+
const rules = reactive({ name: [...rule] })
|
|
13
|
+
const content = reactive(
|
|
14
|
+
[
|
|
15
|
+
{
|
|
16
|
+
type: "input",
|
|
17
|
+
id: "name",
|
|
18
|
+
label: "name",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "input",
|
|
22
|
+
id: "desc",
|
|
23
|
+
label: "desc",
|
|
24
|
+
rules: [...rule],
|
|
25
|
+
},
|
|
26
|
+
]
|
|
27
|
+
);
|
|
28
|
+
</script>
|
|
29
|
+
<style scoped>
|
|
30
|
+
.box {
|
|
31
|
+
margin: 20px 0;
|
|
32
|
+
font-size: 20px;
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="box">set-options</div>
|
|
3
|
+
<el-form-renderer ref="form" :content="content" inline>
|
|
4
|
+
<el-button @click="setOptions">set</el-button>
|
|
5
|
+
</el-form-renderer>
|
|
6
|
+
</template>
|
|
7
|
+
<script setup>
|
|
8
|
+
import { reactive, ref } from "vue";
|
|
9
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
10
|
+
const form = ref();
|
|
11
|
+
const content = reactive([
|
|
12
|
+
{
|
|
13
|
+
id: "area",
|
|
14
|
+
type: "select",
|
|
15
|
+
label: "select",
|
|
16
|
+
el: {
|
|
17
|
+
placeholder: "select",
|
|
18
|
+
},
|
|
19
|
+
options: [
|
|
20
|
+
{
|
|
21
|
+
label: "shanghai",
|
|
22
|
+
value: "shanghai",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "beijing",
|
|
26
|
+
value: "beijing",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
const setOptions = () => {
|
|
33
|
+
form.value.setOptions("area", [
|
|
34
|
+
{
|
|
35
|
+
label: "guangzhou",
|
|
36
|
+
value: "guangzhou",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "hangzhou",
|
|
40
|
+
value: "hangzhou",
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
<style scoped>
|
|
46
|
+
.box {
|
|
47
|
+
margin: 20px 0;
|
|
48
|
+
font-size: 20px;
|
|
49
|
+
}
|
|
50
|
+
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="box">slot</div>
|
|
3
|
+
|
|
4
|
+
<el-form-renderer :content="content">
|
|
5
|
+
<template v-slot:id:age>
|
|
6
|
+
<button type="button">a button insert before age</button>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<template #default>
|
|
10
|
+
<div style="color: #2a7">
|
|
11
|
+
default slot is at the bottom
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
</el-form-renderer>
|
|
15
|
+
</template>
|
|
16
|
+
<script setup>
|
|
17
|
+
import { reactive } from "vue";
|
|
18
|
+
import elFormRenderer from "../components/femessage/el-form-renderer.vue";
|
|
19
|
+
const content = reactive([
|
|
20
|
+
{
|
|
21
|
+
id: 'name',
|
|
22
|
+
label: 'name',
|
|
23
|
+
type: 'input'
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'age',
|
|
27
|
+
label: 'age',
|
|
28
|
+
type: 'input'
|
|
29
|
+
}
|
|
30
|
+
]);
|
|
31
|
+
</script>
|
|
32
|
+
<style scoped>
|
|
33
|
+
.box {
|
|
34
|
+
margin: 20px 0;
|
|
35
|
+
font-size: 20px;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!-- 父组件 ParentCom.vue -->
|
|
2
|
+
<template>
|
|
3
|
+
<ChildCom class="large" @click="onClick" />
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script setup>
|
|
7
|
+
import ChildCom from "../ChildCom.vue";
|
|
8
|
+
const onClick = () => {
|
|
9
|
+
console.log("父组件");
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
<style scoped>
|
|
13
|
+
.large {
|
|
14
|
+
color: red;
|
|
15
|
+
font-size: 32px;
|
|
16
|
+
}
|
|
17
|
+
</style>
|