Vue · VUE0022

Require explicit button type

Require native buttons to declare type so form behavior is explicit.
VUE0022vite-doctor/vuetemplatewarnSuggestion

Run this rule

pnpm vite-doctor . --framework vue --rules vue/template/html-button-has-type

Why it matters

A native button defaults to submit inside forms, which can trigger accidental form submissions.

Add type="button", type="submit", or type="reset" to native buttons.

Example

Use explicit button type

Before

<template>
  <button @click="save">Save</button>
</template>

After

<template>
  <button type="button" @click="save">Save</button>
</template>
Copyright © 2026