vue技巧(七)状态类展示使用红绿圆点

这篇博客介绍了如何在项目中使用红绿圆点图标来代替文字,以更直观地展示状态信息。代码示例展示了在table表格中应用的方法,并提供了绿圆点和红圆点的独立使用代码。通过比较加与不加`margin-left:10px`的样式区别,建议开发者根据实际需求选择合适的样式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通常对于一些在线、离线类的展示使用图标展示比使用文字描述会更加清晰直观。项目中使用的代码如下:

        <el-table-column prop="status" label="状态" width="70%" >
          <template slot-scope="scope" >
            <span slot="reference" v-if="scope.row.status == 1">
              <i class="dotClass" style="background-color: springgreen"></i>
            </span>
            <span slot="reference" v-if="scope.row.status == 0" >
              <i class="dotClass" style="background-color: red"></i>
            </span>
          </template>
        </el-table-column>
.dotClass {
  width:10px;
  height:10px;
  border-radius: 50%;
  display: block;
  margin-left: 10px;  //这个用于圆点居中
}

我们项目中是在table表格中展示的红绿圆点,如果想提取出来单独使用,可以直接拷贝如下代码:

//绿圆点 
<i class="dotClass" style="background-color: springgreen;width:10px;  height:10px;  border-radius: 50%;  display: block"></i>

//红圆点
<i class="dotClass" style="background-color: red ;width:10px;  height:10px;  border-radius: 50%;  display: block"></i>

最后这里展示下不加 margin-left: 10px 和加的区别,具体是否加上这个样式配置根据实际情况选择。

不加:

加:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值