简体   繁体   English

如何解决这个错误 JSONEditor is not defined ESlint

[英]How to solve this error JSONEditor is not defined ESlint

I have a JSON Editor and it works correctly but ESlint keeps giving me this error我有一个 JSON 编辑器,它工作正常,但 ESlint 一直给我这个错误

'JSONEditor' is not defined 'JSONEditor' 未定义

My code exists inside an angularJS 1.7 component.我的代码存在于 angularJS 1.7 组件中。

this.$onInit = function () {
    var container = $document[0].getElementById('jsoneditor');
    var editor = new JSONEditor(container, { mode: 'code' }, json);
    // code to use the editor 
};

Nothing complicated only ESLint not happy with it.没有什么复杂的,只是 ESLint 对此不满意。

ESLint does not know anything about the existence of the class within your code. ESLint 不知道您的代码中是否存在该类。 You can just skip it or comment it out of your code or add it to exceptions您可以跳过它或将其从代码中注释掉或将其添加到异常中

我添加了这一行,它解决了问题

/* global JSONEditor */

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

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