是否可以在LitElements中使用ag-grid-community? 这是我尝试过的,但是无法使用下面的代码初始化ag-grid实例。
控制台错误 - ag-grid-community.auto.esm.js:45056 Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'。
import { Grid } from 'ag-grid-community';
export class myComponent extends LitElement {
static scopedElements = {
'ag-grid': Grid
};
constructor() {
super();
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}
];
this.gridOptions = {
columnDefs: this.columnDefs,
rowData: this.rowData,
};
const eGridDiv = document.querySelector('#myGrid');
new Grid(eGridDiv, this.gridOptions);
}
render() {
return html`
<div>
<ag-grid
.gridOptions=${this.gridOptions}
></ag-grid>
</div>
`;
}
} Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你必须从代码中删除注释文本
另外,我认为你忘记在这里删除逗号:
.gridOptions=${this.gridOptions}