问题描述
在React中如果使用了a
标签,但是又没有给a
标签的href
属性赋值有效的链接地址,则ESLint会警告,看着很烦。
The href attribute is required for an anchor to be keyboard accessible. Provide a valid, navigable address as the href value. If you cannot provide an href, but still need the element to resemble a link, use a button and change it with
appropriate styles. Learn more: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-is-valid.md jsx-a11y/anchor-is-valid
解决方法
在根目录下的package.json
配置文件中添加如下ESLint
的配置:
// .....
"eslintConfig": {
// .....
"rules":{
"jsx-a11y/anchor-is-valid":"off"
}
},
// .....