【问题标题】:How to avoid TSLing warning "Calls to '$' are not allowed. please don't"如何避免 TSLing 警告“不允许调用 '$'。请不要”
【发布时间】:2018-09-04 19:29:53
【问题描述】:

我正在使用 Cheerio 和 angular DataTables,所以我有时使用 $ 从 HTML 中获取原始字符串或添加这样的类

$('td', row).addClass('highlight');

if ($('td', row).eq(3)[0].innerHTML === liqs[cIndex]) { ... }

我也用它把表格发送到打印机

$(win.document.body).find('table')...

有没有办法解决这个问题,还是我应该忽略警告?

【问题讨论】:

  • 警告的确切措辞是什么?
  • 同标题,字面意思是 file.ts[767, 33]: Calls to '$' is not allowed.请不要
  • 你能发布你的 tslint.json 吗?
  • 不能,因为我收到“帖子主要是代码”警告,但我现在看到了问题,我在 tslint.json 中禁用了 $,谢谢
  • 你不应该在你的 Angular 代码中使用 jquery

标签: angular typescript lint


【解决方案1】:

大概这是来自 tslint ban rule。如果您不想遵循此规则,可以在 tslint.json 中将其关闭,或使用 // tslint:disable-next-line 评论来隐藏单个警告。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-21
    • 1970-01-01
    • 2016-12-25
    • 2021-02-04
    • 2014-12-11
    • 1970-01-01
    • 2021-09-08
    • 2012-12-05
    相关资源
    最近更新 更多