AG-grid Vue 不适用于 vuejs 版本 3

AG-grid Vue not working with vuejs version 3

我是 vuejs 的新手,使用 Vuejs 版本 3 设置新项目并安装 ag-grid-vue。 我从官方网站获得了参考 og ag-grid 并按照相同的步骤操作但是当我 运行 项目时我得到了导致页面中断的错误。 该错误仅随 ag-grid 包一起出现,因为当我评论时,ag-grid 页面的导入代码将起作用。我还添加了 @ag-grid-community 包,但仍然出错。我找不到任何解决方案,请帮忙。

我的 package.json ,我使用的是 Vue 版本 3

{
  "name": "vue-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@ag-grid-community/all-modules": "~24.0.0",
    "@ag-grid-community/client-side-row-model": "~24.0.0",
    "@ag-grid-community/core": "~24.0.0",
    "@ag-grid-community/csv-export": "~24.0.0",
    "@ag-grid-community/infinite-row-model": "~24.0.0",
    "@ag-grid-community/vue": "~24.0.0",
    "@ag-grid-enterprise/all-modules": "~24.0.0",
    "core-js": "^3.6.5",
    "vue": "^3.0.0",
    "vue-class-component": "^7.2.6",
    "vue-property-decorator": "^9.0.2",
    "vue-router": "^4.0.0-0",
    "vuex": "^4.0.0-beta.4"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-vue": "^7.0.0-0",
    "prettier": "^1.19.1"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended",
      "@vue/prettier"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

我的带有ag-grid基本示例的视图页面代码,代码复制自google。

<template>
    
    <ag-grid-vue style="width: 100%;" class="flex-grow-1 flex-shrink-1 ag-theme-alpine"
                            :columnDefs="columnDefs"
                            :rowData="rowData"
                            :modules="modules">
        </ag-grid-vue>
    
</template>
<script>
import {AgGridVue} from "@ag-grid-community/vue";
import {AllModules} from "@ag-grid-enterprise/all-modules";
export default {
    name: 'App',
        data() {
            return {
                columnDefs: null,
                rowData: null,
                modules: AllModules
            }
        },
        components: {
            AgGridVue
        },
        beforeMount() {
            this.columnDefs = [
                {headerName: 'Make', field: 'make'},
                {headerName: 'Model', field: 'model'},
                {headerName: 'Price', field: 'price'}
            ];

            this.rowData = [
                {make: 'Toyota', model: 'Celica', price: 35000},
                {make: 'Ford', model: 'Mondeo', price: 32000},
                {make: 'Porsche', model: 'Boxter', price: 72000}
            ];
        }
}
</script>

我在控制台中得到的错误 git bash

错误 git bash

似乎 vue-class-decorator 的依赖项 vue-class-component 还没有更新到 Vue3: https://github.com/vuejs/vue-class-component/issues/406

您应该尝试使用 vue-class-component 库的 8.0.0-beta.3 版本。