我从CoreUI免费管理员Templete那里拿了一个庙宇,但是我不能够 验证CInput插槽。我使用v模型进行验证,但这是 无法使用且无法正常工作如何验证我的登录表单。一世 安装Vuelidate并导入,但仍然无法运行,而不是 我使用“从'vuex'导入{mapState,mapActions}“,但是 还是一样的问题,如何在我的登录表单上提供验证 我使用vuejs 3.1版怎么能验证 Login.vue
<template>
<div id="login">
<CContainer class="d-flex content-center min-vh-100">
<CRow>
<CCol>
<CCardGroup>
<CCard class="p-4">
<CCardBody>
<CForm>
<h1>Login</h1>
<p class="text-muted">Sign In to your account</p>
<CInput
type="text" v-model="data.username" @blur="$v.username.$touch()"
placeholder="Username"
>
<template #prepend-content><CIcon name="cil-user"/></template>
</CInput>
<CInput
placeholder="Password"
type="password" v-model="data.password" @blur="$v.password.$touch()"
>
<template #prepend-content><CIcon name="cil-lock-locked"/></template>
</CInput>
<CRow>
<CCol col="6" class="text-left">
<CButton color="primary" class="px-4" @click="direDisplay">Login</CButton>
</CCol>
<CCol col="6" class="text-right">
<CButton color="link" class="px-0">Forgot password?</CButton>
<CButton color="link" class="d-md-none">Register now!</CButton>
</CCol>
</CRow>
</CForm>
</CCardBody>
</CCard>
<CCard
color="primary"
text-color="white"
class="text-center py-5 d-sm-down-none"
body-wrapper
>
<h2>Sign up</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<CButton
color="primary"
class="active mt-3"
>
Register Now!
</CButton>
</CCard>
</CCardGroup>
</CCol>
</CRow>
</CContainer>
</div>
</template>
<script>
import Dashboard from '../Dashboard.vue';
import { username, required } from 'vuelidate/lib/validators'
import { mapState, mapActions } from 'vuex'
export default {
name: 'Login',
validations: {
username: {
username,
required
},
password:{
password,
requires
},
methods:{
direDisplay(){
this.$router.push('/Dashboard')
}
}
}
</script>