antd学习笔记

antd组件库为Web应用提供了丰富的基础UI组件,antd全称为:ant-design。

antd官网:Ant Design - 一套企业级 UI 设计语言和 React 组件库

一、安装

npm install antd

yarn add antd

 1、antd的使用例子

//在index.js文件中引入

import { 引入的组件 } from 'antd';

//在ReactDOM渲染即可

ReactDOM.render(<组件名 />,mountNode);

//记得引入css样式

import 'antd/dist/antd.css'; 或者 'antd/dist/antd.less'

css的引入是全局引入,引入一次即可

2、创建一个React项目,并导入antd组件库 

1、创建React项目,并运行

create-react-app antd-learn
cd antd-learn
npm run start

2、使用VScode打开该文件夹,并下载antd组件库

code .
npm install antd

3、导入antd组件和css代码

 二、antd的学习

1、Grid栅格系统(24)

24栅格系统,即一行24个单位

 2、Layout布局

构建过程

1、在ant-Design上选中想要的组件样式,复制代码

        注意:复制时,默认复制的是Typescript,而不是JavaScript。

选中喜欢的组件样式后,复制代码

2、新建文件,导入相应的css代码

3、效果展示

上述实例中,页面高度并不是视口高度,可通过css重写,将组件设置为视口高度。

改动如下:

找到css的选择器:

在css中进行重写:

  /* 将页面布局设置为视口高度 */
  .ant-layout {
    height: 100vh;
  }

 效果如下:

3、下拉菜单

import { Button, Dropdown, Space } from 'antd';
import React from 'react';
const items = [
  {
    key: '1',
    label: (
      <a target="_blank" rel="noopener noreferrer" href="https://www.antgroup.com">
        1st menu item
      </a>
    ),
  },
  {
    key: '2',
    label: (
      <a target="_blank" rel="noopener noreferrer" href="https://www.aliyun.com">
        2nd menu item
      </a>
    ),
  },
  {
    key: '3',
    label: (
      <a target="_blank" rel="noopener noreferrer" href="https://www.luohanacademy.com">
        3rd menu item
      </a>
    ),
  },
];
const App = () => (
  <Space direction="vertical">
    <Space wrap>
      <Dropdown
        menu={{
          items,
        }}
        placement="bottomLeft"
      >
        <Button>bottomLeft</Button>
      </Dropdown>
      <Dropdown
        menu={{
          items,
        }}
        placement="bottom"
      >
        <Button>bottom</Button>
      </Dropdown>
      <Dropdown
        menu={{
          items,
        }}
        placement="bottomRight"
      >
        <Button>bottomRight</Button>
      </Dropdown>
    </Space>
    <Space wrap>
      <Dropdown
        menu={{
          items,
        }}
        placement="topLeft"
      >
        <Button>topLeft</Button>
      </Dropdown>
      <Dropdown
        menu={{
          items,
        }}
        placement="top"
      >
        <Button>top</Button>
      </Dropdown>
      <Dropdown
        menu={{
          items,
        }}
        placement="topRight"
      >
        <Button>topRight</Button>
      </Dropdown>
    </Space>
  </Space>
);
export default App;

效果如下:

4、步骤条

import { LoadingOutlined, SmileOutlined, SolutionOutlined, UserOutlined } from '@ant-design/icons';
import { Steps } from 'antd';
import React from 'react';
const App = () => (
  <Steps
    items={[
      {
        title: 'Login',
        status: 'finish',
        icon: <UserOutlined />,
      },
      {
        title: 'Verification',
        status: 'finish',
        icon: <SolutionOutlined />,
      },
      {
        title: 'Pay',
        status: 'process',
        icon: <LoadingOutlined />,
      },
      {
        title: 'Done',
        status: 'wait',
        icon: <SmileOutlined />,
      },
    ]}
  />
);
export default App;

效果如下:

5、轮播组件(走马灯)

import { Carousel } from 'antd';
import React from 'react';
const contentStyle = {
  height: '160px',
  color: '#fff',
  lineHeight: '160px',
  textAlign: 'center',
  background: '#364d79',
};
const App = () => (
  <Carousel autoplay>
    <div>
      <h3 style={contentStyle}>1</h3>
    </div>
    <div>
      <h3 style={contentStyle}>2</h3>
    </div>
    <div>
      <h3 style={contentStyle}>3</h3>
    </div>
    <div>
      <h3 style={contentStyle}>4</h3>
    </div>
  </Carousel>
);
export default App;

6、表格

1、在js中引入Table标签

import { Layout, Menu, Carousel, Table } from 'antd';

<Table dataSource={dataSource} columns={columns} />;

2、在js中写入静态数据

  const dataSource = [
    {
      key: '1',
      name: '张砚拙',
      age: 23,
      address: '西安市雁塔区',
    },
    {
      key: '2',
      name: '不知名',
      age: 22,
      address: '哈尔滨市南岗区',
    },
  ];
  
  const columns = [
    {
      title: '姓名',
      dataIndex: 'name',
      key: 'name',
    },
    {
      title: '年龄',
      dataIndex: 'age',
      key: 'age',
    },
    {
      title: '住址',
      dataIndex: 'address',
      key: 'address',
    },
  ];

3、运行效果

更多组件的使用,查阅文档即可。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
antd admin 是一个基于 Ant Design 设计语言的后台管理系统框架。它提供了丰富的组件和模板,帮助开发者快速搭建出符合企业级标准的后台管理系统。 antd admin 的特点有以下几点: 1. 丰富的组件库:antd admin 提供了很多常用的后台管理系统组件,如菜单、表格、表单、图表等。这些组件都经过了精心设计和优化,具有良好的视觉效果和用户体验。 2. 模块化开发:antd admin 使用了模块化的开发方式,将各个功能拆分成独立的模块,提供了一种灵活的扩展和定制的方式。开发者可以根据自己的需求选择和使用不同的模块,减少了重复开发的工作量。 3. 响应式设计:antd admin 可以自适应不同设备的屏幕大小,包括PC、平板和手机等。这使得后台管理系统在不同设备上都能保持一致的用户体验,提高了系统的易用性和可访问性。 4. 国际化支持:antd admin 内置了国际化的支持,可以轻松地切换不同的语言。这使得后台管理系统可以适应不同国家和地区的用户需求,提高了系统的国际化水平。 5. 定制化主题:antd admin 提供了灵活的主题定制方式,开发者可以根据自己的需求来自定义系统的样式,包括颜色、字体、按钮等。这使得后台管理系统可以与企业的品牌形象保持一致。 总之,antd admin 是一个功能丰富、易用性强、扩展性好的后台管理系统框架。它可以大大加快后台管理系统的开发速度,提高开发效率,同时也提供了一致、美观、易用的用户体验。无论是中小型企业还是大型企业,antd admin 都是一个非常值得考虑的选择。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值