Как правильно отрисовать компонент AgGridVue?
Я использую Vue3 + Composition API + TypeScript + TSX + Ag Grid community. Вот мой компонент, который отрисовывает AgGridVue:
import {defineComponent} from 'vue';
import {AgGridVue} from 'ag-grid-vue';
export default defineComponent({
name: 'GridReportComponent',
render() {
// const columnDefs = [
// {headerName: 'Make', field: 'make'},
// {headerName: 'Model', field: 'model'},
// {headerName: 'Price', field: 'price'}
// ];
//
// const rowData = [
// {make: 'Toyota', model: 'Celica', price: 35000},
// {make: 'Ford', model: 'Mondeo', price: 32000},
// {make: 'Porsche', model: 'Boxter', price: 72000}
// ];
return (
<div class="grid-main">
<AgGridVue />
</div>
)
}
});
Получаю ошибку TS:
'AgGridVue' cannot be used as a JSX component.
Its instance type 'AgGridVue' is not a valid JSX element.
Property '$props' is missing in type 'AgGridVue' but required in type 'ElementClass'.
19 | return (
20 | <div class="grid-main">
> 21 | <AgGridVue />
| ^^^^^^^^^
22 | </div>
23 | )
24 | }
И в консоле:
AgGridVue.js?1283:6 Uncaught TypeError: Object prototype may only be an Object or null: undefined
at setPrototypeOf (<anonymous>)
at extendStatics (AgGridVue.js?1283:6)
at __extends (AgGridVue.js?1283:9)
at eval (AgGridVue.js?1283:27)
at eval (AgGridVue.js?1283:193)
at Module../node_modules/ag-grid-vue/lib/AgGridVue.js (chunk-vendors.js:117)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at eval (main.js?401b:6)
at Object../node_modules/ag-grid-vue/main.js (chunk-vendors.js:165)
Кто сталкивался, как это можно решить ?
Ответы (1 шт):
Автор решения: Yaroslav Molchan
→ Ссылка
Вызывать его нормально, как требует документация:
<ag-grid-vue style="width: 500px; height: 300px;"
class="ag-theme-alpine"
:columnDefs="columnDefs"
:rowData="rowData">
</ag-grid-vue>