【问题标题】:eslint-plugin-vue vue/valid-v-model appears to warn using the rules in Vue.js 2eslint-plugin-vue vue/valid-v-model 似乎使用 Vue.js 2 中的规则发出警告
【发布时间】:2020-11-27 05:57:28
【问题描述】:

我正在使用 Vue.js 3。
以下 eslint-plugin-vue 警告似乎是使用 Vue.js 2 中的规则发出警告。
<MyComponent v-model:propName="foo"/> Vue.js 3 支持这种写作风格。
如何使其与 Vue.js 3 兼容?

<MyInputComponent
  v-model:value="state.value"
/>
// [vue/valid-v-model] 'v-model' directives require no argument. eslint-plugin-vue [7, 9]

.eslintrc.js

module.exports = {
  extends: [
    'plugin:vue/vue3-recommended',
  ]
}

package.json

{
  "name": "ProjectName",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  },
  "dependencies": {
    "typescript": "^4.1.2",
    "vue": "^3.0.2"
  },
  "devDependencies": {
    "@vue/compiler-sfc": "^3.0.2",
    "eslint-plugin-vue": "^7.1.0",
    "vite": "^1.0.0-rc.8"
  }
}

【问题讨论】:

    标签: vue.js eslint vuejs3


    【解决方案1】:

    添加这些部门:

    "@babel/core": "^7.12.10",
    "@babel/eslint-parser": "^7.12.1",
    "eslint": "^7.18.0",
    

    安装它们:

    npm i -D eslint @babel/core @babel/eslint-parser
    

    更改 eslint.js

    parser: '@babel/eslint-parser',
    
    【解决方案2】:

    这对我有用 - 忽略 .eslintrc.js 中的规则:

      rules: {
        "vue/no-v-model-argument": "off",
      },
    

    【讨论】:

      猜你喜欢
      • 2019-05-22
      • 1970-01-01
      • 1970-01-01
      • 2019-02-04
      • 2023-02-03
      • 2018-01-04
      • 2022-01-22
      • 2017-08-01
      • 2021-09-01
      相关资源
      最近更新 更多