vue2使用ag-grid表格

ag-grid官网:Vue Grid: Custom Components | AG Grid

根据官方文档说的AG Grid no longer supports Vue 2. The last version to support Vue 2 is AG Grid v31.3.,目前只有v31.3.版本支持vue2。

以下是官方给的demo

Vue Grid: Get Started with AG Grid | AG GridIn this article, we will walk you through the necessary steps to add AG Grid (both are covered) to an existing Vue project, configure some of the essential features of it. We will show you some of the fundamentals of the grid (passing properties, using the API, etc). As a bonus, we will also tweak the grid's visual appearance using Sass variables. Download AG Grid v32.1.0 today: The best Vue Table & Vue Data Grid in the world.icon-default.png?t=O83Ahttps://www.ag-grid.com/vue-data-grid/vue2/#reference-App.vue

1、在vue组件中引入使用

<template>
  <ag-grid-vue
    style="width: 100%; height: 500px;"
    class="ag-theme-alpine"
    :columnDefs="columnDefs"
    :rowData="rowData"
    :gridOptions="gridOptions"
    @grid-ready="onGridReady"
ag-grid-vue3 是一个用于 Vue3 的数据表格组件,而 element-plus 是一个基于 Vue3 的 UI 组件库。虽然这两个组件库可以独立使用,但是它们可以一起使用以增强 UI 功能。 首先,你需要在项目中安装 element-plus,可以使用 npm 或 yarn 安装,如下所示: ``` npm install element-plus --save ``` 或 ``` yarn add element-plus ``` 安装完成后,在 Vue3 中使用 element-plus 组件,你可以在 main.js 文件中使用以下代码: ```javascript import { createApp } from 'vue' import App from './App.vue' import ElementPlus from 'element-plus' import 'element-plus/lib/theme-chalk/index.css' const app = createApp(App) app.use(ElementPlus) app.mount('#app') ``` 这里我们在 main.js 中导入了 ElementPlus 组件,并使用 app.use(ElementPlus) 将组件注册到 Vue3 中。注意,为了让样式生效,你需要在 main.js 中引入 element-plus/lib/theme-chalk/index.css。 接下来,在 ag-grid-vue3 中使用 element-plus 组件,你可以在 ag-grid-vue3 的 columnDefs 中使用 element-plus 的组件,例如: ```javascript { headerName: '姓名', field: 'name', cellRendererFramework: { template: '<el-button>{{ value }}</el-button>', data() { return { value: '' } }, mounted() { this.value = this.params.value } } } ``` 这里我们在 ag-grid-vue3 的 columnDefs 中使用了 element-plus 的 el-button 组件作为单元格渲染器,这样我们就可以在 ag-grid-vue3 中使用 element-plus 的组件了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值