|
1 | 1 | # Vue 3 Form Generator |
2 | | -A schema-based form generator component for Vue 3, based on `vue-form-generator` |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | +<br> |
| 7 | +A schema-based form generator component for Vue 3, based on the original |
| 8 | +[`vue-form-generator`](https://github.com/vue-generators/vue-form-generator) library. |
3 | 9 |
|
4 | | -## Basic usage |
5 | | -1. Install plugin in your Vue app, this will make all necessary components globally available in your app. |
6 | | -```javascript |
7 | | -// ... |
| 10 | +You can find documentation on the [documentation page](https://kevinkosterr.github.io/vue3-form-generator-docs). |
8 | 11 |
|
9 | | -import VueFormGenerator from '@kevinkosterr/vue3-form-generator' |
10 | | - |
11 | | -app.use(VueFormGenerator) |
12 | | - |
13 | | -// ... |
| 12 | +## Building for development |
| 13 | +1. Install the dependencies |
| 14 | +```bash |
| 15 | +yarn install |
14 | 16 | ``` |
15 | | -2. Define a schema inside your Vue component |
16 | | -<br><br> |
17 | | -#### Composition API: |
18 | | -```vue |
19 | | -<template> |
20 | | - <vue-form-generator :schema="form.schema" :model="form.model"/> |
21 | | -</template> |
22 | | -
|
23 | | -<script setup> |
24 | | - import { ref } from 'vue' |
25 | | - |
26 | | - const form = ref({ |
27 | | - model: { |
28 | | - name: '', |
29 | | - terms: false, |
30 | | - }, |
31 | | - schema: { |
32 | | - fields: [ |
33 | | - { |
34 | | - name: 'name', |
35 | | - label: 'Name', |
36 | | - type: 'input', |
37 | | - inputType: 'text', |
38 | | - model: 'name', |
39 | | - placeholder: "Write name...", |
40 | | - readonly: false, |
41 | | - required: true, |
42 | | - }, |
43 | | - { |
44 | | - name: 'terms', |
45 | | - label: 'Accept terms and conditions', |
46 | | - type: 'input', |
47 | | - inputType: 'checkbox', |
48 | | - model: 'terms', |
49 | | - } |
50 | | - ] |
51 | | - } |
52 | | - }) |
53 | | -</script> |
| 17 | +2. Create a schema inside the playground folder, for this you can copy `schema.example.js`. |
| 18 | +```bash |
| 19 | +cp playground/schema.example.js playground/schema.js |
54 | 20 | ``` |
55 | | -#### Options API: |
56 | | -```vue |
57 | | -<template> |
58 | | - <vue-form-generator :schema="form.schema" :model="form.model"/> |
59 | | -</template> |
60 | | -
|
61 | | -<script> |
62 | | - export default { |
63 | | - data () { |
64 | | - return { |
65 | | - form: { |
66 | | - model: { |
67 | | - name: '', |
68 | | - }, |
69 | | - schema: { |
70 | | - fields: [ |
71 | | - { |
72 | | - name: 'name', |
73 | | - label: 'Name', |
74 | | - type: 'input', |
75 | | - inputType: 'text', |
76 | | - model: 'name', |
77 | | - placeholder: "Write name...", |
78 | | - readonly: false, |
79 | | - required: true, |
80 | | - } |
81 | | - ] |
82 | | - } |
83 | | - } |
84 | | - } |
85 | | - } |
86 | | - } |
87 | | -</script> |
| 21 | +3. Run the development playground |
| 22 | +```bash |
| 23 | +yarn run dev |
88 | 24 | ``` |
89 | 25 |
|
| 26 | + |
0 commit comments