【记录】使用antd-design遇到的问题

这次做前端使用到了antd-design,主页:https://ant.design/docs/react/introduce-cn

使用Select选择器时,<Option>选项中value是必须存在的,不可省略,即<Select> <Option value="lucy">lucy</Option> </Select>,否则会报错。

在 Vue3 中,结合 Ant Design Vue (ant-design-vue) 实现分页表格通常需要以下几个步骤: 1. 安装依赖:首先确保已经安装了 Vue 和 antd-design-vue,可以使用 `npm` 或 `yarn` 来安装: ```bash npm install vue@^3.0 antd @ant-design/icons # 或者 yarn add vue@next antd @ant-design/icons ``` 2. 导入组件:在你的 `.vue` 文件中导入需要的组件,如 `Table`, `Pagination` 和 `Icon`: ```javascript import { Table, Pagination } from 'ant-design-vue'; import PlusOutlined from '@ant-design/icons/PlusOutlined'; ``` 3. 创建数据源:你可以创建一个虚拟的数据数组,模拟分页效果: ```javascript const dataSource = Array.from({ length: 50 }, (_, index) => ({ key: `${index}`, name: `Name ${index + 1}`, age: `Age ${index + 1}`, address: `Address ${index + 1}`, })); ``` 4. 使用 `v-model` 绑定分页插件,并监听它的变化事件来动态加载数据: ```html <template> <div> <a-icon :type="currentMode === 'prev' ? 'chevron-left' : 'chevron-right'" slot="prev" @click="changePage(-1)" /> <Pagination :total="total" :current="currentPage" @on-change="changePage" /> <Table :data="filteredData" :columns="columns" :pagination="pagination" /> <a-icon type="plus" @click="addRow" /> </div> </template> // ... data() { return { currentPage: 1, pageSize: 10, dataSource, total: dataSource.length, columns: [ // ...你的列配置 ], pagination: { pageSizes: [10, 20, 30], // 可选分页大小选项 }, }; }, methods: { changePage(page) { this.currentPage = page; }, filteredData() { return this.dataSource.slice((this.currentPage - 1) * this.pageSize, this.currentPage * this.pageSize); }, addRow() { this.dataSource.push({ // ...添加新的行数据 }); this.total++; } } ``` 5. 根据需求定制表头、排序、搜索等功能,如果需要。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值