Vue 3 with vuelidate@next. Needs a way to reset $v while loading another view.
See original GitHub issueI am using vue-router
, and have some auth forms like below:
{
path: "/auth",
children: [
{
path: "login",
component: () => import("@/views/auth/Login.vue")
},
{
path: "register",
component: () => import("@/views/auth/Register.vue")
}
]
}
I am adding $v
to main.ts
like below:
import { VuelidatePlugin, Validation } from "@vuelidate/core";
declare module "@vue/runtime-core" {
interface ComponentCustomProperties {
$v: Validation;
}
}
createApp(App)
.use(router)
.use(VuelidatePlugin)
.mount("#app");
I am using vuelidate
and dumped {{ $v }}
in both Login.vue
and Register.vue
.
The issue is, if I navigate to register
page first and then to login
page, the {{ $v }}
instance will bring some validation data from the register
page to login
page. For example, we have a name
field which exists in register
page only, but I can dump its data in {{ $v }}
in the login
page.
I understand $v
is registered as a global instance, but should we provide a way for us to programmatically cleanup $v
while navigate to different page via vue-router
?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Vuelidate | A Vue.js model validation library
Simple, lightweight model-based validation for Vue.js.
Read more >Is there a proper way of resetting a component's initial data in ...
I did a small edit to the answer, but only because a vue component requires a function returned for data instead of just...
Read more >The correct way to force Vue to re-render a component
The best way to force Vue to re-render a component is to set a :key on the component. When you need the component...
Read more >Advanced usage - Vuelidate
A simple, but powerful, lightweight model-based validation for Vue.js 3 and 2.
Read more >Conditional Rendering - Vue.js
The directive v-if is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy...
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
I’m having a similar problem. On first page load vuelidade works fine on login page. But after logout when login page is loaded again seens like model is diconnected from $v object and the validation doesn’t work any more.
codesandbox to test: https://codesandbox.io/s/wzibe
This should be fixed with #790