VuetifyのバリデーションをJavaScriptで実行する

html

1
2
3
4
5
<v-form ref="form">
<v-text-field
:rules="[rules.required]"
></v-text-field>
</v-form>

JavaScript

1
2
3
4
5
6
7
8
9
10
11
12
13
// バリデーション
let form = ref(null)
const rules = ref({
required: value => !!value || '',
})

const submit = async () => {
const validResult = await form.value.validate()
if (!validResult.valid) {
return
}
//以下、submitの処理
}
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×