-
Notifications
You must be signed in to change notification settings - Fork 431
TypeError: Cannot read property 'minlength' of undefined #130
Comments
Thank you for the hint. The related issues say that the code Vue.config.warnExpressionErrors = false
Vue.config.debug = false should avoid this problem at least for development and that it will be fixed in the future. But if I apply that two settings I still get the error. In my console I don't get the |
Found the problem. I'm sure it's related to my project setup and not a vue-validator bug. Sorry for the false alarm. If you are interested here are my related files boiled down. index.js import Vue from 'vue'
import router from './router'
import VueValidator from 'vue-validator'
import App from './App.vue'
Vue.use(VueValidator)
router.start(App, '#app') router.js import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from './Home.vue'
import SomeComponentThatUsesValidator from './SomeComponent.vue'
Vue.use(VueRouter)
var router = new VueRouter()
router.map({
'/home': {component: Home, name: 'home'},
'/validatestuff': {component: SomeComponentThatUsesValidator}
})
export default router I think the Problem is that the When I import and use the vue-validator in the beginning of router.js it works. It maybe would be an even better application setup to let router.js export a router factory function which accepts the Vue or so. Or simply integrate the setup from router.js into index.js. But that is really not related to this issue anymore. :) |
No problem 😺 |
@kazupon I'm having this issue as well, using v2.0.0-alpha.18 with vue@1.0.16. This error is thrown and prevents my app from rendering, even if I set
resolveAsset @ vue.common.js?e881:1914 |
@tylersnyder Can you provide the reproduction codes with jsfiddle or etc please ? |
I was unable to reproduce the issue using jsfiddle. http://jsfiddle.net/9x3mxvj0/13/ This helped me realize I was probably misunderstanding something. My project is using webpack and I have many components broken up into separate files. It didn't occur to me that each component may need to I had only added the dependency to my main entry file, similar to how VueRouter is used. After adding the following to each component file, my project seems to be working as expected.
I believe others who are attempting to use your project are running into similar issues - caused by confusion, rather than bugs. Improving documentation may help with this. Thank you for your reply, and your work on this project. |
Thank you for your jsfiddle code. |
@tylersnyder @kazupon |
You can use 'Vue.use' at the entry point. |
I have it like that in my entry point:
before vue-router etc. Any help? |
@mariaczi hello, do you solve this problem for install vue-validator before route.map method? |
@tylersnyder hello, the problem that the plugin users have to install vue-validator plugin for each form component is resolve?
And then, I import and install it in my form component, it work. |
@wklc2014, I was able to load VueValidator in only one spot by putting it in my top level component, App.vue, which is then passed into the router. It looks something like this: App.vue:
router: VueValidator is then passed into all of my child components which are loaded inside of App. I hope this helps! |
@tylersnyder Thank you very much for your help, it work. |
Working solution:
Before this, I've tried the trick in #188 ,which is now added in documentation
THIS DOESN'T WORK, AT LEAST IN MY SITUATION. import Vue from 'vue'
import Validator from 'vue-validator'
Vue.use(Validator)
import Router from 'vue-router'
import App from './components/App.vue'
//import other components
Vue.use(Router)
Vue.use(Resource) the @kazupon So, I think this "bug" may not only related to the installation sequence, and the documentation probably write this solution down. |
@tylersnyder I love you man, you saved my life...
If I need form validation in a component, just do it:
P.S: No need to do this in entry file before |
With vue 1.0.14 and vue-validator 2.0.0-alpha.9 I get this TypeError when my component that contains a validator with
<input type="text" v-validate:comment="{ minlength: 16, maxlength: 128 }">
is loading. Thus the component won't show up.My components data attribute is like:
When I change something e.g. the minlength to 5, the component is reloaded by webpack hot module reload and then the component and the validator works.
Is this a vue-validator bug or is something wrong with my setup?
Here is the Error Stack
The text was updated successfully, but these errors were encountered: