首页 > 解决方案 > AG-Grid 在 IE11 中出现 vue 错误 挂载钩子中的错误:“TypeError:无法获取未定义或空引用的属性 'addEventListener'”

问题描述

我正在使用带有 VUE CLI 的 ag grid 社区版

Everytings 在 chrome、firefox 和 safari 上运行良好,但我在 IE 11 中遇到错误

错误说:

[Vue 警告]:挂载钩子中的错误:“TypeError:无法获取未定义或空引用的属性‘addEventListener’”

“无法获取未定义或空引用的属性‘addEventListener’”

这是我在 vue 中的代码

<template>
<div>
    <button @click="getSelectedRows()">Get Selected Rows</button>

    <ag-grid-vue style="width: 500px; height: 500px;"
             class="ag-theme-balham"
             :columnDefs="columnDefs"
             :rowData="rowData">
    </ag-grid-vue>
    </div>
</template>
<style lang="scss" scoped>

</style>
<script>
import {AgGridVue} from 'ag-grid-vue'
export default {
    components:{
        AgGridVue
    },
    data(){
        return{
            columnDefs:null,
            rowData:null,
            gridApi: null,
            columnApi: null,
            autoGroupColumnDef: null,
        }
    },
    methods : {
        onGridReady : function(params){
            this.gridApi = params.api;
            this.columnApi = params.columnApi;

            
        },
        getSelectedRows : function(){
            const selectedNodes = this.gridApi.getSelectedNodes();
            const selectedData = selectedNodes.map(node => node.data);
            const selectedDataStringPresentation = selectedData.map(node => node.make + ' ' + node.model).join(', ');
            console.log(selectedDataStringPresentation);
        }
    },
    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>

标签: javascriptvue.jsag-grid

解决方案


它认为babel-polyfill必须在 ag-grid 之前导入。


推荐阅读