vuejs3下安装vee-validate报错

Install vee-validate under vuejs3 I got error

在vuejs3下我用命令安装vee-validate

yarn add vee-validate@next

成功后我 运行 服务器在

上出现错误
$ yarn run serve            
yarn run v1.22.5
$ vue-cli-service serve
 INFO  Starting development server...
98% after emitting CopyPlugin
ERROR  Failed to compile with 1 errors                                                                                                                                                                   
    2:07:01 PM

This dependency was not found:

* vee-validate/dist/rules in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/components/auth/Login.vue?vue&type=script&lang=js

To install it, you can run: npm install --save vee-validate/dist/rules
Error from chokidar (/mnt/_work_sdb8/wwwroot): Error: Circular symlink detected: "/mnt/_work_sdb8/wwwroot/wwwroot" points to "/mnt/_work_sdb8/wwwroot"

我将 vuejs 2 应用程序中的代码粘贴为:

<script>
  import { bus } from '../../../src/main'
  import appMixin from '@/appMixin'

  import { ValidationObserver, ValidationProvider, extend } from 'vee-validate'
  import * as rules from 'vee-validate/dist/rules'

  Object.keys(rules).forEach(rule => {
    extend(rule, rules[rule])
  })

  export default {
    name: 'loginPage',
    mixins: [appMixin],

    components: {
      ValidationObserver,
      ValidationProvider
    },

但在这里阅读 https://github.com/logaretm/vee-validate 我没有看到我必须申请的 vuejs 3 是否有一些语法更改?

package.json:
{
  "name": "yt3",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "axios": "^0.20.0-0",
    "core-js": "^3.6.5",
    "mitt": "^2.1.0",
    "moment-timezone": "^0.5.31",
    "node-sass": "^4.12.0",
    "sass-loader": "^10.0.4",
    "vee-validate": "^4.0.0-beta.16",
    "vue": "^3.0.0",
    "vue-router": "^4.0.0-rc.1",
    "vuex": "^4.0.0-rc.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-standard": "^5.1.2",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^7.0.0-0"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    }
  }
}

修改块: 我添加了行

 "vee-validate": "^3.1.0" 

在package.json文件和运行ning命令中

 yarn

 yarn run serve

我在浏览器的控制台中遇到错误:

vee-validate.esm.js?7bb1:867 Uncaught TypeError: vue__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor
    at eval (vee-validate.esm.js?7bb1:867)
    at Module../node_modules/vee-validate/dist/vee-validate.esm.js (chunk-vendors.js:3389)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader-v16/dist/index.js?!./src/components/auth/Login.vue?vue&type=script&lang=js:10)
    at Module../node_modules/cache-

看起来 vee-validate 3 和 vuejs 3 不兼容?
您建议使用哪些 vuejs 3 验证工具?

谢谢!

关于 Github Migration Guide for version 4 问题的一些评论:

  • 由于API完全不同
  • ,因此没有直接升级途径
  • 即使让人们知道 v4 适用于 Vue 3 而 v3 适用于 Vue2 也会对人们有用

SO:vee-validate 的 V4 仅适用于 Vue 3,与 V3(仅适用于 Vue 2)有很大的不同 API

也来自V4 guide is seems they decided to throw away build-in validators in favor of using specialized library like yup

因此,使用现有 Vue 2 应用程序中的任何代码都没有任何意义 - 如果您使用的是 Vue 3:

  • vee-validate:使用 V4 指南并使用新的 API 重新编写代码......
  • 做好准备,很多 已建立的库 还没有 Vue 3 的稳定版本....这就是我的原因我在任何严肃的项目中至少使用 Vue 2 6 个月(一边玩 Vue 3)