【发布时间】:2019-11-10 08:48:27
【问题描述】:
如何通过nuxt.config文件集成ag-grid与nuxt.js一起工作?
我得到的错误:
commons.app.js:16278 未捕获的类型错误:无法读取 null 的属性“_init”
在 AgGridVue (commons.app.js:16278)
在 Function.Vue.use (commons.app.js:16233)
在 Module../plugins/ag-grid.client.js (app.js:5186)
在 webpack_require (runtime.js:791)
在 fn (runtime.js:151)
在 Module../.nuxt/index.js (app.js:1997)
在 webpack_require (runtime.js:791)
在 fn (runtime.js:151)
在模块。 (app.js:236)
在 Module../.nuxt/client.js (app.js:1308)
ag-grid.client.js:
import Vue from "vue";
import { AgGridVue } from "ag-grid-vue";
Vue.use(AgGridVue);
nuxt.config.js:
plugins: [
"@/plugins/element-ui",
"@/plugins/tooltip",
"@/plugins/calendar",
"@/plugins/ag-grid.client.js"
],
要加载表格的文件:
<template>
<div class="flex h-full">
<no-ssr>
<ag-grid-vue style="width: 500px; height: 500px;"
class="ag-theme-balham"
:columnDefs="columnDefs"
:rowData="rowData">
</ag-grid-vue>
</no-ssr>
</div>
</template>
<script>
export default {
components: {},
data() {
return {
columnDefs: null,
rowData: null
};
},
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>
【问题讨论】: