Skip to content

Commit 2d300de

Browse files
committed
feat(alias): component aliases
1 parent 2bed2f5 commit 2d300de

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/fields/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import FieldSelect from '@/fields/input/FieldSelect.vue'
55
import FieldRadio from '@/fields/input/FieldRadio.vue'
66
import FieldColor from '@/fields/input/FieldColor.vue'
77
import FieldNumber from '@/fields/input/FieldNumber.vue'
8+
import FieldSwitch from '@/fields/input/FieldSwitch.vue'
89

910
import FieldSubmit from '@/fields/buttons/FieldSubmit.vue'
1011
import FieldReset from '@/fields/buttons/FieldReset.vue'
1112
import FieldButton from '@/fields/buttons/FieldButton.vue'
12-
import FieldSwitch from '@/fields/input/FieldSwitch.vue'
1313

1414

1515
const fieldComponents = [
@@ -18,9 +18,14 @@ const fieldComponents = [
1818
]
1919

2020
export default {
21-
install (app) {
21+
install (app, aliases) {
2222
for (const fieldComponent of fieldComponents) {
23-
app.component(fieldComponent.name, fieldComponent)
23+
const alias = aliases[fieldComponent.name]
24+
if (alias) {
25+
app.component(alias, fieldComponent)
26+
} else {
27+
app.component(fieldComponent.name, fieldComponent)
28+
}
2429
}
2530
}
2631
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const VueFormGenerator = {
1010
install (app, options) {
1111
if (!options) options = {}
1212

13-
app.use(FormGeneratorFields)
13+
app.use(FormGeneratorFields, options.aliases ?? {})
1414
app.component('VueFormGenerator', FormGenerator)
1515

1616
if (isObject(options.messages)) {

0 commit comments

Comments
 (0)