简体   繁体   English

eslint-plugin-vue vue/valid-v-model 似乎使用 Vue.js 2 中的规则发出警告

[英]eslint-plugin-vue vue/valid-v-model appears to warn using the rules in Vue.js 2

I'm using Vue.js 3.我正在使用 Vue.js 3。
The following eslint-plugin-vue warning appears to warn using the rules in Vue.js 2.以下 eslint-plugin-vue 警告似乎使用 Vue.js 2 中的规则发出警告。
<MyComponent v-model:propName="foo"/> This writing style is supported in Vue.js 3. <MyComponent v-model:propName="foo"/> Vue.js 3 支持这种写法。
How to make it compatible with 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 .eslintrc.js

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

package.json 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"
  }
}

Add these deps:添加这些部门:

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

install them:安装它们:

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

change eslint.js更改 eslint.js

parser: '@babel/eslint-parser',

This worked for me - ignore the rule in .eslintrc.js :这对我有用 - 忽略.eslintrc.js中的规则:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM