AG-grid Vue not working with vuejs version 3

2k Views Asked by At

I am new with vuejs and setup new project with Vuejs version 3 and install ag-grid-vue. I got reference og ag-grid from official website and follow the same step but when I run the project I got the error which break the page. The error only come with ag-grid package because when i comment the import code of ag-grid page will work. I also add the @ag-grid-community package but still error comming. I can't find any solution please help.

My package.json , I am using Vue version 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"
  ]
}

My view page code with basic example of ag-grid, code copy get from 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>

error what I getting in Console and git bash

enter image description here

error in git bash

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

it seems like vue-class-decorator's dependency vue-class-component has not been updated to Vue3: https://github.com/vuejs/vue-class-component/issues/406

0
On

You should try using version 8.0.0-beta.3 of vue-class-component library.