使用UI组件库antd

  1. npm install --save antd,安装antd。
  2. App.js中引入antd的样式文件,引入antd的Button组件。
import React, { Component } from 'react'
import { Button } from 'antd';

// import 'antd/dist/antd.css';
import 'antd/dist/antd.min.css'

export default class App extends Component {
  render() {
    return (
      <div>
        <button>点我</button>&nbsp;
        <Button type="primary">按钮1</Button>&nbsp;
        <Button type="default">按钮2</Button>&nbsp;
        <Button type="link">按钮4</Button>
      </div>
    )
  }
}

导入antd的css文件:antd/dist/antd.css时,npm start 启动应用时遇到如下警告:
Failed to parse source map: ‘webpack://antd/./components/time-picker/style/index.less’ URL is not supported
所以改用了antd/dist/antd.min.css

在这里插入图片描述

  1. App.js从antd的子库@ant-design/icons中引入图标组件,如微信图标、微博图标。
import React, { Component } from 'react'
import { Button } from 'antd';
import {WechatOutlined,WeiboOutlined} from '@ant-design/icons'

import 'antd/dist/antd.min.css'

export default class App extends Component {
  render() {
    return (
      <div>
        <button>点我</button>&nbsp;
        <Button type="primary">按钮1</Button>&nbsp;
        <Button type="default">按钮2</Button>&nbsp;
        <Button type="link">按钮4</Button>&nbsp;
        
        <WechatOutlined />&nbsp;
        <WeiboOutlined />
      </div>
    )
  }
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用Ant Design Vue的Table组件和Expandable组件来实现表格嵌套表格的功能。 首先,你需要在你的Vue项目中安装和引入Ant Design Vue和其样式。 然后,你可以使用Ant Design Vue的Table组件来创建你的主表格,并设置Expandable属性为true来启用嵌套表格的功能。 接着,在Table组件的columns属性中,你可以定义主表格的列和嵌套表格的列。对于嵌套表格的列,你可以使用Expandable组件的render属性来自定义每个嵌套行的展示内容。 最后,你可以在Table组件的dataSource属性中设置你的数据,包括主表格和嵌套表格的数据。 下面是一个简单的示例代码: ``` <template> <a-table :columns="columns" :data-source="data" :expandable="expandable"> <template slot="expand" slot-scope="{ record }"> <a-table :columns="nestedColumns" :data-source="record.children"> <template slot="description" slot-scope="{ text }"> <span v-html="text" /> </template> </a-table> </template> </a-table> </template> <script> import { Table, Tag } from 'ant-design-vue'; export default { components: { Table, Tag }, data() { return { expandable: { expandedRowRender: (record) => { return ( <a-table :columns="nestedColumns" :data-source="record.children"> <a-table-column title="Name" dataIndex="name" /> <a-table-column title="Age" dataIndex="age" /> <a-table-column title="Description" dataIndex="description" customRender={(text) => <span v-html="text" />} /> </a-table> ); }, rowExpandable: (record) => record.children.length > 0, }, columns: [ { title: 'Name', dataIndex: 'name', key: 'name', }, { title: 'Age', dataIndex: 'age', key: 'age', }, { title: 'Tags', key: 'tags', dataIndex: 'tags', customRender: (tags) => ( <span> {tags.map((tag) => ( <Tag color="blue" key={tag}> {tag} </Tag> ))} </span> ), }, { title: 'Action', key: 'action', customRender: (text, record) => ( <span> <a>Invite {record.name}</a> <a-divider type="vertical" /> <a>Delete</a> </span> ), }, ], nestedColumns: [ { title: 'Name', dataIndex: 'name', }, { title: 'Age', dataIndex: 'age', }, { title: 'Description', dataIndex: 'description', customRender: (text) => <span v-html="text" />, }, ], data: [ { key: '1', name: 'John Brown', age: 32, tags: ['nice', 'developer'], children: [ { key: '1-1', name: 'Jim Green', age: 42, description: '<strong>Jim Green Description</strong>', }, { key: '1-2', name: 'Joe Black', age: 32, description: '<strong>Joe Black Description</strong>', }, ], }, { key: '2', name: 'Jim Red', age: 42, tags: ['loser'], children: [ { key: '2-1', name: 'Jim Green', age: 42, description: '<strong>Jim Green Description</strong>', }, { key: '2-2', name: 'Joe Black', age: 32, description: '<strong>Joe Black Description</strong>', }, ], }, { key: '3', name: 'Joe Black', age: 32, tags: ['cool', 'teacher'], children: [], }, ], }; }, }; </script> ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值