最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Ant?Design?組件庫之步驟條實(shí)現(xiàn)

 更新時(shí)間:2022年08月19日 15:03:41   作者:極智視界  
這篇文章主要為大家介紹了Ant?Design組件庫之步驟條實(shí)現(xiàn),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

引言

antd 組件庫是基于 Ant Design 設(shè)計(jì)體系的 React UI 組件庫,antd 為 Web 應(yīng)用提供了豐富的基礎(chǔ) UI 組件,可以用于研發(fā)企業(yè)級(jí)中后臺(tái)產(chǎn)品。這篇咱們介紹 antd 組件庫之 步驟條。

1 antd 之 Steps API

步驟條 Steps 的用處是在 當(dāng)任務(wù)復(fù)雜或者存在先后關(guān)系時(shí),將其分解成一系列的步驟,從而達(dá)到簡(jiǎn)化任務(wù)的目的。其 DOM 節(jié)點(diǎn)為 :

<Steps>
  <Step>...</Step>
  <Step>...</Step>
  <Step>...</Step>
</Steps>

antd 中的步驟條樣式豐富,可以通過設(shè)置 Steps 和 Step 的屬性來產(chǎn)生不同的 步驟條 樣式,詳細(xì)的這里我進(jìn)行一個(gè)整理:

下面做一些實(shí)踐。

2 antd 之 Steps 示例

先來看最簡(jiǎn)單的靜態(tài)的步驟條,看代碼:

import { Steps } from 'antd';
import React from 'react';
const { Step } = Steps;
const App = () => (
  <Steps current={1}>
    <Step title="Finished" description="This is a description." />
    <Step title="In Progress" subTitle="Left 00:00:08" description="This is a description." />
    <Step title="Waiting" description="This is a description." />
  </Steps>
);
export default App;

可以看到現(xiàn)在 current 默認(rèn)選擇了 1,來看效果:

如果 current 我們選擇了 2, 那會(huì)是什么樣子的呢:

再來看一個(gè) 帶圖標(biāo)的步驟條,這里用了 antd 的 icon,上代碼:

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

來看效果:

來有意思一些的,看看動(dòng)態(tài)的吧:配合按鈕進(jìn)行步進(jìn)或后退,來表示一個(gè)流程的處理進(jìn)度,上代碼:

import { Button, message, Steps } from 'antd';
import React, { useState } from 'react';
const { Step } = Steps;
const steps = [
  {
    title: 'First',
    content: 'First-content',
  },
  {
    title: 'Second',
    content: 'Second-content',
  },
  {
    title: 'Last',
    content: 'Last-content',
  },
];
const App = () => {
  const [current, setCurrent] = useState(0);
  const next = () => {
    setCurrent(current + 1);
  };
  const prev = () => {
    setCurrent(current - 1);
  };
  return (
    <>
      <Steps current={current}>
        {steps.map((item) => (
          <Step key={item.title} title={item.title} />
        ))}
      </Steps>
      <div className="steps-content">{steps[current].content}</div>
      <div className="steps-action">
        {current < steps.length - 1 && (
          <Button type="primary" onClick={() => next()}>
            Next
          </Button>
        )}
        {current === steps.length - 1 && (
          <Button type="primary" onClick={() => message.success('Processing complete!')}>
            Done
          </Button>
        )}
        {current > 0 && (
          <Button
            style={{
              margin: '0 8px',
            }}
            onClick={() => prev()}
          >
            Previous
          </Button>
        )}
      </div>
    </>
  );
};
export default App;

還有 CSS 代碼,同級(jí)目錄下寫個(gè) index.less

.steps-content {
    min-height: 200px;
    margin-top: 16px;
    padding-top: 80px;
    text-align: center;
    background-color: #fafafa;
    border: 1px dashed #e9e9e9;
    border-radius: 2px;
  }
  .steps-action {
    margin-top: 24px;
  }

來看效果:

步驟條還可以通過 Steps 的 status 屬性來指定當(dāng)前步驟的狀態(tài),來看示例:

import { Steps } from 'antd';
import React from 'react';
const { Step } = Steps;
const App = () => (
  <Steps current={1} status="error">
    <Step title="Finished" description="This is a description" />
    <Step title="In Process" description="This is a description" />
    <Step title="Waiting" description="This is a description" />
  </Steps>
);
export default App;

來看效果,這里是第 1 步出現(xiàn) err 了:

咱們也可以給步驟條的每個(gè)步驟添加自定義的展示,上代碼:

import { Popover, Steps } from 'antd';
import React from 'react';
const { Step } = Steps;
const customDot = (dot, { status, index }) => (
  <Popover
    content={
      <span>
        step {index} status: {status}
      </span>
    }
  >
    {dot}
  </Popover>
);
const App = () => (
  <Steps current={1} progressDot={customDot}>
    <Step title="Finished" description="You can hover on the dot." />
    <Step title="In Progress" description="You can hover on the dot." />
    <Step title="Waiting" description="You can hover on the dot." />
    <Step title="Waiting" description="You can hover on the dot." />
  </Steps>
);
export default App;

來看效果:

最后來看一個(gè) Steps 中的 Step 可點(diǎn)擊的步驟條,上代碼:

import { Divider, Steps } from 'antd';
import React, { useState } from 'react';
const { Step } = Steps;
const App = () => {
  const [current, setCurrent] = useState(0);
  const onChange = (value) => {
    console.log('onChange:', current);
    setCurrent(value);
  };
  return (
    <>
      <Steps current={current} onChange={onChange}>
        <Step title="Step 1" description="This is a description." />
        <Step title="Step 2" description="This is a description." />
        <Step title="Step 3" description="This is a description." />
      </Steps>
      <Divider />
      <Steps current={current} onChange={onChange} direction="vertical">
        <Step title="Step 1" description="This is a description." />
        <Step title="Step 2" description="This is a description." />
        <Step title="Step 3" description="This is a description." />
      </Steps>
    </>
  );
};
export default App;

從上面的代碼可以看到,當(dāng)你點(diǎn)擊 change Steps 的時(shí)候,會(huì)觸發(fā) onChange 回調(diào)函數(shù),咱們這里的 onChange 只做了兩件事情:

(1) 控制臺(tái)打印 current,current 大家應(yīng)該熟悉,就是第幾個(gè) Step;

(2) 設(shè)置 setCurrent。這個(gè)地方不限于此,盡可以發(fā)揮想象。

來看效果:

好了,以上分享了 Ant Design 組件庫之步驟條。

更多關(guān)于Ant Design 組件庫步驟條的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • React中classnames庫使用示例

    React中classnames庫使用示例

    這篇文章主要為大家介紹了React中classnames庫使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-10-10
  • React Native之TextInput組件解析示例

    React Native之TextInput組件解析示例

    本篇文章主要介紹了React Native之TextInput組件解析示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-08-08
  • react-router中<Link/>的屬性詳解

    react-router中<Link/>的屬性詳解

    這篇文章主要給大家介紹了關(guān)于react-router中<Link/>屬性的相關(guān)資料,文中介紹的非常詳細(xì),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧。
    2017-06-06
  • React?組件傳?children?的各種案例方案詳解

    React?組件傳?children?的各種案例方案詳解

    自定義組件的時(shí)候往往需要傳?children,由于寫法比較多樣,我就總結(jié)了一下,要自定義的組件其中包含一個(gè)?title?和一個(gè)?children,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧
    2023-10-10
  • React中獲取數(shù)據(jù)的3種方法及優(yōu)缺點(diǎn)

    React中獲取數(shù)據(jù)的3種方法及優(yōu)缺點(diǎn)

    這篇文章主要介紹了React中獲取數(shù)據(jù)的3種方法及優(yōu)缺點(diǎn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-02-02
  • React實(shí)現(xiàn)createElement 和 cloneElement的區(qū)別

    React實(shí)現(xiàn)createElement 和 cloneElement的區(qū)別

    本文詳細(xì)介紹了React中React.createElement和React.cloneElement兩種方法的定義、用法、區(qū)別及適用場(chǎng)景,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-09-09
  • 詳解react關(guān)于事件綁定this的四種方式

    詳解react關(guān)于事件綁定this的四種方式

    這篇文章主要介紹了詳解react關(guān)于事件綁定this的四種方式,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-03-03
  • 詳解React中如何拆分組件

    詳解React中如何拆分組件

    這篇文章主要為大家詳細(xì)介紹了React中拆分組件的相關(guān)知識(shí),文中的示例代碼講解詳細(xì),對(duì)我們掌握React有一定的幫助,需要的小伙伴可以參考一下
    2023-12-12
  • react同構(gòu)實(shí)踐之實(shí)現(xiàn)自己的同構(gòu)模板

    react同構(gòu)實(shí)踐之實(shí)現(xiàn)自己的同構(gòu)模板

    這篇文章主要介紹了react同構(gòu)實(shí)踐之實(shí)現(xiàn)自己的同構(gòu)模板,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • 淺談React的React.FC與React.Component的使用

    淺談React的React.FC與React.Component的使用

    本文主要介紹了React的React.FC與React.Component的使用,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09

最新評(píng)論

随州市| 叙永县| 大渡口区| 东丽区| 沙洋县| 大石桥市| 拉孜县| 高阳县| 亳州市| 常德市| 宜州市| 库车县| 永胜县| 乌鲁木齐市| 彰化县| 会泽县| 福安市| 七台河市| 平定县| 全椒县| 东光县| 乃东县| 双桥区| 专栏| 黄梅县| 满洲里市| 哈巴河县| 五家渠市| 洪江市| 花莲县| 烟台市| 普安县| 岢岚县| 新化县| 云南省| 石楼县| 张家港市| 墨竹工卡县| 汉川市| 布拖县| 乌鲁木齐市|