通过script标签注入的全局变量eslint报错未定义解决方案
如下通过script注入的全局变量在代码中是会提示如下错误的(eslint)
我们需要在.eslintrc.js文件下配置globals配置项如下:
module.exports = {
root: true,
env: {
node: true
},
extends: ["plugin:vue/recommended", "eslint:recommended"],
parserOptions: {
parser: "babel-eslint",
},
globals: {
ol: true
},
rules: {
indent: [2, 2],
"no-console": "off",
"no-debugger": "off",
"vue/html-self-closing": 0,
"vue/max-attributes-per-line": 0,
"vue/singleline-html-element-content-newline": 0,
'Strings must use singlequote': 0
}
}
解决