如何在 ES6 中使用 ag-grid?
How to use ag-grid with ES6?
我想将 ag-grid 与 ES6 模块一起使用。我没能找到
任何例子。这是我目前所拥有的:
import { Grid, ClientSideRowModelModule } from "/node_modules/ag-grid-community/dist/ag-grid-community.esm.min.js"
class Index {
constructor() {
//grid setup
this.gridOptions = {
components: {
rowModelType: ClientSideRowModelModule
},
columnDefs: [
{headerName: 'id', field: 'id'},
{headerName: 'serial', field: 'serial'},
]
};
let eGridDiv = document.querySelector('#grid');
new Grid(eGridDiv, this.gridOptions);
}
}
new Index()
但在控制台中出现此错误:
AG Grid: could not find matching row model for rowModelType clientSide
AG Grid: Row Model "Client Side" not found. Please ensure the @ag-grid-community/client-side-row-model is registered.';
我该如何注册组件?一个小的工作示例将是一个很好的开始。
更改此行:
new Grid(eGridDiv, this.gridOptions);
对此:
new Grid(eGridDiv, this.gridOptions, { modules: [ClientSideRowModelModule] });
我想将 ag-grid 与 ES6 模块一起使用。我没能找到 任何例子。这是我目前所拥有的:
import { Grid, ClientSideRowModelModule } from "/node_modules/ag-grid-community/dist/ag-grid-community.esm.min.js"
class Index {
constructor() {
//grid setup
this.gridOptions = {
components: {
rowModelType: ClientSideRowModelModule
},
columnDefs: [
{headerName: 'id', field: 'id'},
{headerName: 'serial', field: 'serial'},
]
};
let eGridDiv = document.querySelector('#grid');
new Grid(eGridDiv, this.gridOptions);
}
}
new Index()
但在控制台中出现此错误:
AG Grid: could not find matching row model for rowModelType clientSide
AG Grid: Row Model "Client Side" not found. Please ensure the @ag-grid-community/client-side-row-model is registered.';
我该如何注册组件?一个小的工作示例将是一个很好的开始。
更改此行:
new Grid(eGridDiv, this.gridOptions);
对此:
new Grid(eGridDiv, this.gridOptions, { modules: [ClientSideRowModelModule] });