vue项目开发的时候,因为启动了eslint
经常会出现一些代码变红错误!下面web建站小编给大家简单介绍一下解决方法!
打开.eslintrc.js文件,检查一下自己的代码配置,如下:
module.exports = { root: true, parserOptions: { parser: 'babel-eslint' }, env: { browser: true, }, extends: [ 'plugin:vue/essential', 'standard' ], // required to lint *.vue files plugins: [ 'vue' ], // add your custom rules here rules: { // allow async-await 'generator-star-spacing': 'off', // allow debugger during development 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', "vue/no-use-v-if-with-v-for": ["error", { "allowUsingIterationVar": false }], "vue/return-in-computed-property": ["error", { "treatUndefinedAsUnspecified": false }], "vue/no-unused-components": ["error", { "ignoreWhenBindingPresent": true }], "vue/attribute-hyphenation": ["error", "always", { "ignore": [] }], "vue/component-name-in-template-casing": ["error", "kebab-case", { "ignores": [] }], "vue/html-closing-bracket-newline": ["error", { "singleline": "never", "multiline": "always" }], "vue/html-closing-bracket-spacing": ["error", { "startTag": "never", "endTag": "never", "selfClosingTag": "always" }], "vue/html-indent": ["error", 2, { "attribute": 1, "baseIndent": 1, "closeBracket": 0, "alignAttributesVertically": true, "ignores": [] }], "vue/html-quotes": ["error", "double"], "vue/html-self-closing": ["error", { "html": { "void": "never", "normal": "never", "component": "always" }, "svg": "always", "math": "always" }], "vue/max-attributes-per-line": ["error", { "singleline": 3, "multiline": { "max": 3, "allowFirstLine": true } }], "vue/multiline-html-element-content-newline": ["error", { "ignoreWhenEmpty": true, "ignores": ["pre", "textarea"] }], "vue/mustache-interpolation-spacing": ["error", "always"], "vue/name-property-casing": ["error", "kebab-case"], "vue/no-multi-spaces": ["error", { "ignoreProperties": false }], "vue/no-spaces-around-equal-signs-in-attribute": ["error"], "vue/no-template-shadow": ["error"], "vue/prop-name-casing": ["error", "camelCase"], "vue/require-default-prop": ["error"], "vue/v-bind-style": ["error", "shorthand"], "vue/v-on-style": ["error", "shorthand"], "vue/attributes-order": ["error", { "order": [ "DEFINITION", "LIST_RENDERING", "CONDITIONALS", "RENDER_MODIFIERS", "GLOBAL", "UNIQUE", "TWO_WAY_BINDING", "OTHER_DIRECTIVES", "OTHER_ATTR", "EVENTS", "CONTENT" ] }], "vue/order-in-components": ["error", { "order": [ "el", "name", "parent", "functional", ["delimiters", "comments"], ["components", "directives", "filters"], "extends", "mixins", "inheritAttrs", "model", ["props", "propsData"], "data", "computed", "watch", "LIFECYCLE_HOOKS", "methods", ["template", "render"], "renderError" ] }], "vue/this-in-template": ["error", "never"] } }
PS:根据上面的配置,如果没有的加起来,再重新运行项目!
标签: eslint检测
上面是“vue开发中关于eslint代码配置检查说明”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4033.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!