Uncaught ReferenceError: VueFormGenerator is not defined
See original GitHub issueCurrently trying out vue-form-generator 2.0.beta1 with vuejs 2.1.6 - and everything is working well so far.
I had a little issue trying to get validators working. I’m using webpack & components and I was getting this error in the console, when trying to load a form that used a validator:
Uncaught ReferenceError: VueFormGenerator is not defined
at VueComponent.data (eval at <anonymous> (app.js:912), <anonymous>:40:22)
at initData (eval at <anonymous> (app.js:630), <anonymous>:1887:12)
at initState (eval at <anonymous> (app.js:630), <anonymous>:1838:3)
at VueComponent.Vue._init (eval at <anonymous> (app.js:630), <anonymous>:3294:5)
at new VueComponent (eval at <anonymous> (app.js:630), <anonymous>:3414:12)
at createComponentInstanceForVnode (eval at <anonymous> (app.js:630), <anonymous>:2484:10)
at init (eval at <anonymous> (app.js:630), <anonymous>:2494:31)
at eval (eval at <anonymous> (app.js:630), <anonymous>:2654:5)
at createComponent (eval at <anonymous> (app.js:630), <anonymous>:4052:9)
at createElm (eval at <anonymous> (app.js:630), <anonymous>:3995:9)
this would be reporting the line number in my .vue
file that was setting the validator:
property of a field:
...
validator: VueFormGenerator.validators.string
...
I’m sure this probably isn’t the correct way to do this, but to get this to work, I ended up adding this in my main.js
file, to create a global reference that I can use:
window.VueFormGenerator = VueFormGenerator
Here’s all the relevant code:
main.js
import Vue from 'vue'
import VueFormGenerator from 'vue-form-generator'
Vue.use(VueFormGenerator)
window.VueFormGenerator = VueFormGenerator
import MyComponent from './components/MyComponent.vue'
MyComponent.vue
<template lang='html'>
<div id='my-component'>
<form>
<vue-form-generator :schema='schema' :model='model' :options='formOptions'></vue-form-generator>
</form>
</div>
</template>
<script>
export default {
name: 'my-component',
data () {
return {
model: {
password: 'J0hnD03!x4'
},
schema: {
fields: [
{
type: 'input',
inputType: 'password',
label: 'Password',
model: 'password',
min: 6,
required: true,
hint: 'Minimum 6 characters',
validator: VueFormGenerator.validators.string
}
]
}
}
}
}
</script>
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
vue-form-generator example - JSFiddle - Code Playground
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
Read more >Vuejs2- Issue in vue-form-generator - Stack Overflow
1 Answer 1 · No it's not working. I have copied ur code & paste in my file. · Did you remove Vue.use(VueFormGenerator);...
Read more >[Solved]-Vue not Defined-Vue.js - appsloveworld
How to properly apply ternary operator in v-model in vue.js? The vue-form-generator github repo states it supports "custom styles". Where's the documentation?
Read more >vuejs/vue - Gitter
ReferenceError : axios is not defined. do I need to register it as a module via Vue options? Noel da Costa. @geoidesic. Mar...
Read more >Uncaught ReferenceError: Vue is not defined - Laracasts
Uncaught ReferenceError : Vue is not defined. i watched the tutorial lets "flash messaging with vue - lets build a forum", i installed...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Awesome, thank you! Also, thank you very much for all your hard work on vue-form-generator - very much appreciated 😃
Also, maybe this could go into the docs, somewhere, if it’s not already?
Yes, because the imported
VueFormGenerator
is an object, what contains the component, validators and schema utils. So if you would like to use the component, use this form:Other solution (as at validators)
But if you need the component and validators too