eslint / eslint-plugin-react:< form action =“" Javascript:void(0)" > -无脚本网址错误 [英] eslint / eslint-plugin-react: <form action="Javascript:void(0)" > - no-script-url error

查看:294
本文介绍了eslint / eslint-plugin-react:< form action =“" Javascript:void(0)" > -无脚本网址错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下形式的组件:

I have a component with a form:


<表单action = javascript:void(0) onSubmit = {this.join}>

< form action="javascript:void(0)" onSubmit={this.join}>

Eslint抱怨:


错误脚本URL是eval no-script-url的一种形式

error Script URL is a form of eval no-script-url

注意:我也在使用 eslint-plugin-react

Note: I am also using "eslint-plugin-react"

我如何放宽此规则,或者可以替代javascript void函数?

How can I relax this rule or what would be an alternative to the javascript void function?

推荐答案

只是这个问题,然后在Redux官方文档中看到了这种模式,这对我来说很有意义:

I was having just this problem and then saw this pattern in the official Redux docs and it made a lot of sense to me:

<a
  href=""
  onClick={e => {
    e.preventDefault()
    onClick()
  }}
>
  {children}
</a>

来源

这就是我从现在开始要做的事情。

That's what I'll be doing from now on.

这篇关于eslint / eslint-plugin-react:&lt; form action =“&quot; Javascript:void(0)&quot; &gt; -无脚本网址错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆