错误'_'未定义no-undef [英] error '_' is not defined no-undef

查看:78
本文介绍了错误'_'未定义no-undef的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用eslint检查我的代码,并发生错误-未定义错误'_'no-undef".

I use eslint to check my code ,and a error happen -- "error '_' is not defined no-undef".

我这样写代码:

new webpack.ProvidePlugin({
    $: "jquery",//jquery
    jQuery: "jquery",
    "window.jQuery": "jquery",
    _:"lodash"//lodash
})

并获取.eslintrc.js,部分内容如下:

and get .eslintrc.js, part of it like this:

"env": {
    "browser": true,
    "commonjs": true,
    "es6": true,
    "jquery":true,
},

在将jquery添加到之前,它会发生一个错误-错误'_'未定义为no-undef".但是,当我将lodash添加到时,就像'lodash':true"一样.它不起作用.

before I add the jquery into ,it happen an error -- "error '_' is not defined no-undef". However, when I add lodash into ,just like that "'lodash':true".It doesn't work.

你能帮我吗?

推荐答案

ESLint无法理解lodash库.您需要在配置中添加一个全局部分.

ESLint doesn't understand lodash library. you need to add a global section in your config.

全局变量":{_: 真的}

"globals": { "_": true },

这篇关于错误'_'未定义no-undef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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