问题
I use eslint to check my code ,and a error happen -- "error '_' is not defined no-undef".
I write the code like this:
new webpack.ProvidePlugin({
$: "jquery",//jquery
jQuery: "jquery",
"window.jQuery": "jquery",
_:"lodash"//lodash
})
and get .eslintrc.js, part of it like this:
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jquery":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.
Can you help me?
回答1:
ESLint doesn't understand lodash library. you need to add a global section in your config.
"globals": { "_": true },
来源:https://stackoverflow.com/questions/45317154/error-is-not-defined-no-undef