I am a new full-stack developer student and I want to use Vue-Form-Generator to generate a form with input fields and I want to browse an image. All of my fields works except the image browse one. It doesn’t displays on my page. I tried a lot of things, but my last hope is someone who could know it.
My Vue.js code :
JavaScript
x
79
79
1
<div class="page">
2
<h2>Ajout d'un chercheur</h2>
3
<div class="form">
4
<vue-form-generator :schema="schema" :model="model" :options="formOptions"></vue-form-generator>
5
</div>
6
</div>
7
</template>
8
9
<script>
10
11
export default {
12
data () {
13
return {
14
model: {
15
avatar: null,
16
prenom: 'Prénom',
17
nom: 'Nom',
18
url: 'www.son_site.fr'
19
},
20
schema: {
21
fields: [
22
{
23
type: "image",
24
label: "Photo",
25
model: "avatar",
26
placeholder: "Photographie du chercheur",
27
browse: true,
28
required: true,
29
featured:true,
30
},
31
{
32
type: 'input',
33
inputType: 'text',
34
label: 'Prénom',
35
model: 'prenom',
36
placeholder: 'Prénom',
37
featured: true,
38
required: true
39
},
40
{
41
type: 'input',
42
inputType: 'text',
43
label: 'Name',
44
model: 'nom',
45
placeholder: 'Nom',
46
featured: true,
47
required: true
48
},
49
{
50
type: 'input',
51
inputType: 'text',
52
label: 'URL / Site Web',
53
model: 'url',
54
placeholder: 'www.son_site.fr',
55
featured: true,
56
required: true
57
},
58
{
59
type: 'submit',
60
onSubmit(model) {
61
console.log(model);
62
},
63
label: '',
64
buttonText: "Ajouter",
65
validateBeforeSubmit: true
66
},
67
]
68
},
69
formOptions: {
70
validateAfterLoad: true,
71
validateAfterChanged: true,
72
validateAsync: true
73
}
74
}
75
}
76
}
77
78
</script>
79
What it displays : my page with everything except the image browse
Advertisement
Answer
Given the console error you have, looks like you are using the “Core” rather than “Full” version of Vue-Form-Generator.
See the docs here for how to use the full version, which includes all field types. The image field type is not in the core version.
JavaScript
1
12
12
1
// the "full" way
2
<script>
3
import VueFormGenerator from "vue-form-generator";
4
import "vue-form-generator/dist/vfg.css"; // optional full css additions
5
</script>
6
7
// the "core" way
8
<script>
9
import VueFormGenerator from "vue-form-generator/dist/vfg-core.js";
10
import "vue-form-generator/dist/vfg-core.css"; // optional core css additions
11
</script>
12