Iview form verification how to debug, click unresponsive, only know that the verification failed

related codes

https://jsfiddle.net/1m503vc6/1/

it can be executed here, but it can"t be executed in practice. I don"t know what"s wrong with it. Can verification be debugged? Find out what went wrong

Feb.18,2022

that's not the point. Add prop, where you want to verify, and then you need to write validation rules
< template >

.
<Form ref="formInline" :model="formInline" :rules="ruleInline" inline>
    <FormItem prop="user">
        <Input type="text" v-model="formInline.user" placeholder="Username">
            <Icon type="ios-person-outline" slot="prepend"></Icon>
        </Input>
    </FormItem>
    <FormItem prop="password">
        <Input type="password" v-model="formInline.password" placeholder="Password">
            <Icon type="ios-lock-outline" slot="prepend"></Icon>
        </Input>
    </FormItem>
    <FormItem>
        <Button type="primary" @click="handleSubmit('formInline')">Signin</Button>
    </FormItem>
</Form>

< / template >
< script >

export default {
    data () {
        return {
            formInline: {
                user: '',
                password: ''
            },
            ruleInline: {
                user: [
                    { required: true, message: 'Please fill in the user name', trigger: 'blur' }
                ],
                password: [
                    { required: true, message: 'Please fill in the password.', trigger: 'blur' },
                    { type: 'string', min: 6, message: 'The password length cannot be less than 6 bits', trigger: 'blur' }
                ]
            }
        }
    },
    methods: {
        handleSubmit(name) {
            this.$refs[name].validate((valid) => {
                if (valid) {
                    this.$Message.success('Success!');
                } else {
                    this.$Message.error('Fail!');
                }
            })
        }
    }
}

< / script >
this demo on the official website should be able to help you

Menu