a11y/landmark-roles
验证地标角色的位置及唯一性。
| 默认严重程度 | 预设 | 自动修复 | 选项 |
|---|---|---|---|
warning |
nuxt, opinionated |
不支持 | 无 |
适用范围:Vue SFC 模板和代码块,包括规则所需的脚本上下文。
错误示例
同一模板中的两个 main 元素声明了重复的主地标。
<template>
<main>Dashboard</main>
<main>Settings</main>
</template>
正确示例
仪表盘保留为主地标;设置区域改为具名的导航地标。
<template>
<main>Dashboard</main>
<nav aria-label="Settings">...</nav>
</template>
配置(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"a11y/landmark-roles": "warn"
}
},
});
然后运行 vp run lint。