Lighthouse 错误:“按钮没有可访问的名称”

Meh*_*etk 5 html accessibility htmlbutton

如何修复此灯塔错误:

按钮没有可访问的名称

<button class="search-button" type="submit" value="Search"></button>
Run Code Online (Sandbox Code Playgroud)

我是初学者。

Jak*_*des 10

我会推荐这个链接以供参考。

https://developers.google.com/web/tools/lighthouse/audits/button-name

它建议按钮应该具有内部文本内容或 aria-label 或 aria-labelledBy。

<button class="search-button" type="submit">Search</button>

<button class="search-button" type="submit" aria-label="search"></button>
Run Code Online (Sandbox Code Playgroud)

我已经展示了一个带有内部文本的按钮和一个带有 aria-label 的按钮。

  • “它表明按钮应该具有内部文本内容,以及一个 aria-label 或 aria-labelledBy。” 它只需要内部文本或 aria-label 而不需要两者。 (4认同)