antd+vue的steps组件在步骤条中添加自定义样式内容(上)

步骤条的图标比较单调,需要替换成有特定图标,从图库里选择需要的图标替换上去,改变之前的步骤条:
在这里插入图片描述
替换图标之后的步骤条:
核心:
如果antd中steps组件中提供的图标有时候能满足我们的要求,可以使用框架中本身提供的icon来实现:使用slot插槽来实现

在这里插入图片描述
实现代码如下:

<template>
  <a-row :gutter="24">
    <a-col :md="24">
      <a-card title="步骤条">
        <a-switch
          checked-children="横向"
          un-checked-children="纵向"
          default-checked
          @change="changeDir"
          class="btn-sw"
        />
        <a-steps :current="current - 1" :direction="direction">
          <a-step v-for="(item,index) in steps" :key="index" :title="item.name">
            <a-icon slot="icon" :type="getIconType(item.type)"></a-icon>
            <span slot="description">
              <li :key="ind" v-for="( ite, ind ) in item.info">
                <p>{{ "用户名:" }}{{ ite.userName }}</p>
                <p>{{ "评价:" }}{{ ite.comment }}</p>
              </li>
            </span>
          </a-step>
        </a-steps>
      </a-card>
    </a-col>
  </a-row>
</template>

<script>
export default {
  data () {
    return {
      direction: 'horizontal',
      current: 3,
      steps: [
        {
          id: 'sdf',
          name: 'first',
          type: 0,
          info: [{ userName: 'Amily', userId: '001', comment: 'aaaaaaaaaaaaa' }]
        },
        {
          id: 'fgh',
          name: 'second',
          type: 1,
          info: [{ userName: 'Bill', userId: '002', comment: 'aaaaadsaew' }]
        },
        {
          id: 'wrg',
          name: 'third',
          type: 2,
          info: [{ userName: 'Claire', userId: '003', comment: 'fdrewdaaaaa' }]
        },
        {
          id: 'jhm',
          name: 'fourth',
          type: 3,
          info: [{ userName: 'Damon', userId: '004', comment: 'fhghyfaaaa' }]
        }
      ]
    }
  },
  methods: {
    getIconType (type) {
      let icon = null
      switch (type) {
        case 0:
          icon = 'user'
          break
        case 1:
          icon = 'smile'
          break
        case 2:
          icon = 'edit'
          break
        case 3:
          icon = 'check-circle'
          break
        default:
          icon = null
      }
      return icon
    },
    changeDir (checked) {
      if (checked) {
        this.direction = 'horizontal'
      } else {
        this.direction = 'vertical'
      }
    }
  }
}
</script>
<style lang="less" scoped>
.btn-sw {
  margin-bottom: 20px;
}
/deep/.ant-steps-item-process .ant-steps-item-icon {
    background: transparent;
}
</style>

如果antd中steps组件中提供的图标不能满足我们的要求,需要使用自定义的图片来实现,antd+vue的steps组件在步骤条中添加自定义样式内容(下)

  • 2
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要搭建一个基于Vite、Ant Design和Vue 3的项目,你可以按照以下步骤进行操作: 1. 首先,你需要安装Vite。你可以通过运行以下命令来安装最新版本的Vite: ``` npm init vite@latest my-project cd my-project npm install ``` 这将创建一个新的Vite项目,并安装所有必要的依赖项。 2. 接下来,你需要安装Ant Design Vue。运行以下命令来安装Ant Design Vue库: ``` npm install ant-design-vue@next ``` 这将安装最新版本的Ant Design Vue,并将其添加到你的项目中。 3. 配置路由。你可以通过以下步骤来配置Vue Router: - 首先,运行以下命令来安装Vue Router: ``` npm install vue-router@next ``` - 在你的项目的src目录下创建一个名为"router"的文件夹。 - 在"router"文件夹中创建一个名为"index.js"的文件,并配置你的路由信息。 - 最后,在项目的"main.js"文件中引入并使用Vue Router。 以上是使用Vite、Ant Design VueVue 3搭建项目的基本步骤。你可以根据需要进一步添加其他功能和组件。祝你搭建项目成功!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [vue3+vite+antd 后台管理系统基础模板](https://download.csdn.net/download/yehaocheng520/87420798)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [vite + vue3 + Antd 搭建后台管理系统](https://blog.csdn.net/m0_58094704/article/details/127850749)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值