Cannot read property ‘numerator‘ of undefined,calc的运算

calc计算进度条时出现的错误

如下图的写法第一句的时候报错了,第二句的时候可以显示出需要的效果
在这里插入图片描述
calc里面的内容是计算出来的,precent2,precent分别是进度条的当前值和总值。

效果如下图

在这里插入图片描述
代码如下HTML

<div class="zhenProgress">
    <div class="bar"
     :style="`--precent2: ${item.grade};--precent: ${maxBusiness}`"></div>
 </div>
.zhenProgress {
        width: 200px;
        .bar {
          width: 90%;
          background-color: rgba(232, 237, 250, 0.9);
        }
        .bar::before {
          display: block;
          counter-reset: progress var(--precent2);
          content: counter(progress);
          //   width: calc(100% * var(--precent2) / var(--precent));
          width: ~"calc(100% * var(--precent2) / var(--precent))";
          color: #fff;
          background-color: rgba(0, 193, 255, 1);
          text-align: center;
          white-space: nowrap;
        }
      }

查找资料得知在less中计算操作不一样,资料来源calc的~

那么在这当中的区别就是需要calc之前加~,然后后面的代码用引号包起来就解决了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值