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 的基本示例,代码副本来自谷歌。

<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 中的错误

在此处输入图像描述

4

2 回答 2

2

好像vue-class-decorator的依赖vue-class-component没有更新到 Vue3:https ://github.com/vuejs/vue-class-component/issues/406

于 2020-10-26T09:44:26.907 回答
0

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

于 2021-04-13T21:29:03.517 回答