svg的简单使用


<template>
  <div id="pro">
    <button style="display:block;margin:0 auto" :disabled="disabled" @click="begin">开始</button>
    <!-- 内置图形:
      rect(矩形)    
      circle(圆)  
      ellipse(椭圆)   
      line(直线)   
      polyline(折线)  
      polygon(多边形)  
      path(路径)
    -->
    <!-- 内置样式
      fill(填充颜色)   
      fill-opacity(填充透明度)
      stroke(边框颜色)   
      stroke-width(边框宽度)   
      stroke-opacity(边框透明度)   
      stroke-dasharray(定义实线虚线的长度)
      stroke-dashoffset(定义实线/虚线的起点距离 路径 的起点的距离)
      transform(变换)
      filter(滤镜)(url[#滤镜id)]
    -->
    <svg style="width:300px;height:300px">
      <!-- r代表圆的半径;cx、cy代表圆心坐标;fill代表填充颜色,这里是透明 -->
      <circle r="50" cx="100" cy="100" fill="transparent" class="bg" />
      <circle
        r="50"
        cx="100"
        cy="100"
        fill="transparent"
        class="inner"
        stroke-dasharray="314"
        :stroke-dashoffset="progress"
      />
      <!-- 上面 stroke-dasharray="314"  314是圆的周长,2πr = 2 x 3.14 x 50 -->
      <!-- 定义了实线长度为314,stroke-dashoffset可以通过动态绑定来控制 -->
    </svg>
  </div>
</template>

.bg {
  stroke-width: 8px; /* 设置边框宽度 */
  stroke: red; /* 设置边框颜色 */
}

.inner {
  stroke-width: 8px; /* 设置边框宽度 */
  stroke: blue; /* 设置边框颜色 */
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值