1

我在表单中有一个以下字段,用户可以为地址创建/添加另一个字段。如何验证名称 = 地址的所有字段

<v-col cols="12">
    <v-text-field v-for="(item, index) in address" :key="index"
        :value=item.value
        name=address[]
        prepend-icon="home_office"
        placeholder="Address"
    ></v-text-field>
</v-col>

脚本部分:

<script>

export default {
    name: "Contact",
    data: () => ({
        dialog: false,
        valid: false,
        firstName: '',
        lastName: '',
        nameRules: [
            v => !!v || 'Name is required',
            v => v.length >= 3 || 'Name must be more than 3 characters',
            v => v.length <= 255 || 'Name must be less than 255 characters',
        ],
        address: [
            {
                value: ''
            },
            {
                value: 'Test2'
            }
        ]
    }),
    methods: {
        create(){
            this.$store.dispatch('createContact')
            .then(response => {
                console.log(response);
            })
        },
        submit () {
            console.log(this.$refs.form.validate());

            // this.$refs.form.validate()
        },
        clear () {
            this.$refs.form.reset()
        }
    },
}
</script>
4

0 回答 0