a11y/iframe-has-title
要求 iframe 元素具有 title 属性。
| 默认严重程度 | 预设 | 自动修复 | 选项 |
|---|---|---|---|
warning |
happy-path, nuxt, ecosystem, opinionated |
不支持 | 无 |
适用范围:Vue SFC 模板和代码块,包括规则所需的脚本上下文。
错误示例
结账框架有来源 URL,却没有描述嵌入内容的 title。
<template>
<iframe src="/checkout"></iframe>
</template>
正确示例
title="Checkout preview" 为该框架的内容命名。
<template>
<iframe src="/checkout" title="Checkout preview"></iframe>
</template>
配置(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"a11y/iframe-has-title": "warn"
}
},
});
然后运行 vp run lint。