简体   繁体   English

如何清除以下错误的逃逸警告: <br\\> 在jshint中

[英]How to remove Bad Escaping warning for <br\> in jshint

In my code I am trying to introduce a line break after every 11 characters. 在我的代码中,我试图在每11个字符后引入一个换行符。 I have an angular filter for the same which works just fine. 我有一个相同的角度过滤器,效果很好。 The problem is that jsHint is throwing a warning "Bad Escaping" for every <br\\> that I have put in. How to suppress the warning for "Bad Escaping" for jshint. 问题是jsHint对我放入的每个<br\\> \\>都发出警告“ Bad Escaping”。如何抑制jshint的“ Bad Escaping”警告。

Note: I tried to replace the <br\\> with a "\\n" but "\\n" is not working properly and was displaying unpredictable behavior. 注意:我试图将<br\\>替换为“ \\ n”,但是“ \\ n”无法正常工作,并且显示了不可预测的行为。 Hence kindly do not suggest to replace the same. 因此,请不要建议将其替换。 Please see the code snippet below to observe how I am using <br\\> . 请查看下面的代码片段,以观察我如何使用<br\\>

if(labelArrayParts.length === 0){
                                    breakPart = value.slice(0,10) + "-" + "<br\>";
                                    leftPart = value.slice(10,value.length);
                                    labelArrayParts[i] = breakPart;
                                    labelArrayParts[i+1] = leftPart;
                                }

Remove the escape character. 删除转义符。 Leave everything else alone. 别的一切。

"<br>";

If you are trying to write XHTML (which I wouldn't recommend as it is more trouble than it is worth, and if you are making this mistake then you won't be getting any benefit from it) then the syntax for an empty element is <br /> not <br\\> . 如果您正在尝试编写XHTML(我不建议这样做,因为它麻烦多于其应有的价值,并且如果您犯了此错误,那么您将无法从中获得任何好处),那么空元素的语法是<br /><br\\>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM