我在这里按照示例进行操作。
一切正常,现在我想检测一行点击并获取事件的数据。
这是我的App.vue
:
<template>
<ag-grid-vue style="width: 500px; height: 500px;"
class="ag-theme-alpine"
:columnDefs="columnDefs"
:rowData="rowData"
:rowClicked="onRowClicked"
>
</ag-grid-vue>
</template>
<script>
import {AgGridVue} from "ag-grid-vue";
export default {
name: 'App',
data() {
return {
columnDefs: null,
rowData: null
}
},
components: {
AgGridVue
},
methods:{
onRowClicked(params) {
console.log(params);
console.log(params.node.data);
}
},
beforeMount() {
this.columnDefs = [
{headerName: 'Make', field: 'make', sortable: true, filter: true },
{headerName: 'Model', field: 'model', sortable: true, filter: true },
{headerName: 'Price', field: 'price', sortable: true, filter: true }
];
fetch('https://raw.githubusercontent.com/ag-grid/ag-grid/master/grid-packages/ag-grid-docs/src/sample-data/smallRowData.json')
.then(result => result.json())
.then(rowData => this.rowData = rowData);
}
}
</script>
<style>
@import "../node_modules/ag-grid-community/dist/styles/ag-grid.css";
@import "../node_modules/ag-grid-community/dist/styles/ag-theme-alpine.css";
</style>
但是,onRowClicked
当我单击一行时,不会调用该方法。
我在这里缺少什么?