【问题标题】:AG-Grid with vue error in IE11 Error in mounted hook: "TypeError: Unable to get property 'addEventListener' of undefined or null reference"AG-Grid 在 IE11 中出现 vue 错误 挂载钩子中的错误:“TypeError:无法获取未定义或空引用的属性 'addEventListener'”
【发布时间】:2020-01-10 01:06:50
【问题描述】:

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

在 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>

【问题讨论】:

    标签: javascript vue.js ag-grid


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-03-28
      • 2020-08-14
      • 2021-07-14
      • 1970-01-01
      • 2019-05-19
      • 2020-09-01
      • 2017-11-14
      • 1970-01-01
      • 2018-12-04
      相关资源
      最近更新 更多