Vuelidate as Nuxt Plugin not working
See original GitHub issueHi everyone,
Setup:
Nuxt@2.6.1
and Vuelidate@0.7.4
Problem: I’m having trouble getting Vuelidate to work with Nuxt and I’ve tried searching for hours without any success.
I’ve created the following vuelidate.js
file in my plugins
folder:
import Vue from "vue"
import Vuelidate from "vuelidate"
Vue.use(Vuelidate)
Then in my Nuxt.config.js
, I added the following to my plugins:
plugins: [someotherpackages..., { src: "~/plugins/vuelidate" }]
In my components:
<template>
<form @submit.prevent="test">
<input type="email" name="email" v-model.trim="$v.email.model">
<p v-if="!$v.email.required">The email field is required!</p>
<p v-if="!$v.email.email">The input must be a proper email!</p>
<input type="password" name="password" v-model.trim="$v.password.model">
<button type="submit">Submit</button>
</form>
</div>
</template>
<script>
import { required, minLength } from "vuelidate/lib/validators"
export default {
name: "SignUp",
data() {
return {
email: null,
password: null,
}
},
validations: {
email: required,
password: {
required,
minLength: minLength(6),
},
},
}
I get the following error:
[Vue warn]: Property or method "$v" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Nuxt 2 & Vuelidate 2 not working properly - Stack Overflow
I have installed vuelidate 2 to validate forms in my NuxtJS project. I followed instructions for installation and setup according to ...
Read more >Plugins directory - Nuxt
The plugins directory contains your Javascript plugins that you want to run before instantiating the root Vue.js Application.
Read more >Vuelidate | A Vue.js model validation library
Simple, lightweight model-based validation for Vue.js.
Read more >How to create dynamic forms with custom validation in ...
In this article we'll show you how to easily set-up dynamic forms with custom validation using Storyblok, Nuxt.js, Vuelidate and TailwindCSS.
Read more >nuxt-vuelidate-module - npm Package Health Analysis - Snyk
The npm package nuxt-vuelidate-module was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as ......
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
@chanmathew HI! I made a codesandbox with latest nuxt and vuelidate that is working: https://codesandbox.io/s/53jwkw9r9k
few things:
$v.email.$model
( note the $ before model )Please check the component VueliForm and the plugin vuelidate.
Worked for me this way, hope it helps.
plugins/vuelidate.js
nuxt.config.js
MyComponent.vue