Vue3加载中(Spin)

简介: 该加载组件 `Spin.vue` 可高度自定义加载状态,包括是否显示加载 (`spinning`)、尺寸 (`size`)、描述文案 (`tip`)、加载指示符 (`indicator`) 及其颜色 (`color`) 和其他细节参数。支持多种加载样式如点、线、圆环等,并允许调整动画速度和初始旋转状态。组件基于 Vue 构建,易于集成到任何项目中,提供丰富的视觉反馈。

可自定义设置以下属性:

  • 是否为加载中状态(spinning),类型:boolean,默认 true

  • 加载中尺寸(size),类型:'small' | 'middle' | 'large',默认 'middle'

  • 描述文案(tip),类型:string,默认 undefined

  • 加载指示符(indicator),类型:'dot' | 'spin-dot' | 'spin-line' | 'ring-circle' | 'ring-rail' | 'dynamic-circle' | 'magic-ring',默认 'dot'

  • 指示符颜色(color),类型:string,默认 '#1677ff',当 indicator: 'magic-ring' 时为外环颜色

  • 圆环宽度(spinCircleWidth),单位是加载指示符宽度的百分比,类型:number,默认 12,仅当 indicator: 'ring-circle' | 'ring-rail' 时生效

  • 圆环长度百分比 (0~100)(spinCirclePercent),单位是圆环周长的百分比,类型:number,默认 33,仅当 indicator: 'ring-circle' | 'ring-rail' 时生效

  • 圆环轨道颜色(ringRailColor),类型:string,默认 'rgba(0, 0, 0, 0.12)',仅当 indicator: 'ring-rail' 时生效

  • 内环颜色(magicRingColor),仅当 indicator: 'magic-ring' 时生效,类型:string,默认 '#4096ff'

  • spin-dot 或 spin-line 初始是否旋转(rotate),类型:boolean,默认:false,仅当 indicator: 'spin-dot' | 'spin-line' 时生效

  • spin-dot 或 spin-line 渐变旋转的动画速度(speed),类型:number,单位ms,默认 800,仅当 'indicator: spin-dot' | 'spin-line' 时生效

效果如下图:在线预览

①创建加载中组件Spin.vue:

<script setup lang="ts">
import { computed } from 'vue'
interface Props {
  spinning?: boolean // 是否为加载中状态
  size?: 'small' | 'middle' | 'large' // 加载中尺寸
  tip?: string // 描述文案
  indicator?: 'dot' | 'spin-dot' | 'spin-line' | 'ring-circle' | 'ring-rail' | 'dynamic-circle' | 'magic-ring' // 加载指示符
  color?: string // 指示符颜色,当 indicator: 'magic-ring' 时为外环颜色
  spinCircleWidth?: number // 圆环宽度,单位是加载指示符宽度的百分比,仅当 indicator: 'ring-circle' | 'ring-rail' 时生效
  spinCirclePercent?: number // 圆环长度百分比 (0~100),单位是圆环周长的百分比,仅当 indicator: 'ring-circle' | 'ring-rail' 时生效
  ringRailColor?: string // 圆环轨道颜色,仅当 indicator: 'ring-rail' 时生效
  magicRingColor?: string // 内环颜色,仅当 indicator: 'magic-ring' 时生效
  rotate?: boolean // spin-dot 或 spin-line 初始是否旋转,仅当 indicator: 'spin-dot' | 'spin-line' 时生效
  speed?: number // spin-dot 或 spin-line 渐变旋转的动画速度,单位 ms,仅当 indicator: 'spin-dot' | 'spin-line' 时生效
}
const props = withDefaults(defineProps<Props>(), {
  spinning: true,
  size: 'middle',
  tip: undefined,
  indicator: 'dot',
  color: '#1677ff',
  spinCircleWidth: 12,
  spinCirclePercent: 33,
  ringRailColor: 'rgba(0, 0, 0, 0.12)',
  magicRingColor: '#4096ff',
  rotate: false,
  speed: 800
})
const circlePerimeter = computed(() => {
  // 圆环周长
  return (100 - props.spinCircleWidth) * Math.PI
})
const circlePath = computed(() => {
  // 圆环轨道路径指令
  const long = 100 - props.spinCircleWidth
  return `M 50,50 m 0,-${long / 2}
   a ${long / 2},${long / 2} 0 1 1 0,${long}
   a ${long / 2},${long / 2} 0 1 1 0,-${long}`
})
</script>
<template>
  <div
    :class="`m-spin-wrap spin-${size}`"
    :style="`--color: ${color}; --magic-ring-color: ${magicRingColor}; --spin-circle-width: ${spinCircleWidth}; --speed: ${speed}ms;`"
  >
    <div class="m-spin" v-show="spinning">
      <div class="m-spin-box">
        <div v-if="indicator === 'dot'" class="m-loading-dot">
          <span class="dot-item"></span>
          <span class="dot-item"></span>
          <span class="dot-item"></span>
          <span class="dot-item"></span>
        </div>
        <div v-if="indicator === 'spin-dot'" class="spin-wrap-box" :class="{ 'spin-box-rotate': rotate }">
          <div class="m-spin-dot">
            <span class="spin-item"></span>
            <span class="spin-item"></span>
            <span class="spin-item"></span>
            <span class="spin-item"></span>
          </div>
          <div class="m-spin-dot spin-rotate" :class="{ 'has-tip': tip }">
            <span class="spin-item"></span>
            <span class="spin-item"></span>
            <span class="spin-item"></span>
            <span class="spin-item"></span>
          </div>
        </div>
        <div v-if="indicator === 'spin-line'" class="spin-wrap-box" :class="{ 'spin-box-rotate': rotate }">
          <div class="m-spin-line">
            <span class="spin-item"></span>
            <span class="spin-item"></span>
            <span class="spin-item"></span>
            <span class="spin-item"></span>
          </div>
          <div class="m-spin-line spin-rotate" :class="{ 'has-tip': tip }">
            <span class="spin-item"></span>
            <span class="spin-item"></span>
            <span class="spin-item"></span>
            <span class="spin-item"></span>
          </div>
        </div>
        <div v-if="indicator === 'ring-circle'" class="m-ring-circle">
          <svg class="circle" viewBox="0 0 100 100">
            <path
              :d="circlePath"
              stroke-linecap="round"
              class="path"
              :style="`stroke-dasharray: ${(spinCirclePercent / 100) * circlePerimeter}px, ${circlePerimeter}px;`"
              fill-opacity="0"
            ></path>
          </svg>
        </div>
        <div v-if="indicator === 'ring-rail'" class="m-ring-rail">
          <svg class="circle" viewBox="0 0 100 100">
            <path
              :d="circlePath"
              :stroke="ringRailColor"
              stroke-linecap="round"
              class="trail"
              :style="`stroke-dasharray: ${circlePerimeter}px, ${circlePerimeter}px;`"
              fill-opacity="0"
            ></path>
            <path
              :d="circlePath"
              stroke-linecap="round"
              class="path"
              :style="`stroke-dasharray: ${(spinCirclePercent / 100) * circlePerimeter}px, ${circlePerimeter}px;`"
              fill-opacity="0"
            ></path>
          </svg>
        </div>
        <div v-if="indicator === 'dynamic-circle'" class="m-dynamic-circle">
          <svg class="circle" viewBox="0 0 50 50">
            <circle class="path" cx="25" cy="25" r="20" fill="none"></circle>
          </svg>
        </div>
        <div v-if="indicator === 'magic-ring'" class="m-magic-ring">
          <div class="outer-ring"></div>
          <div class="inner-ring"></div>
        </div>
        <p class="spin-tip" v-show="tip">{
  
  { tip }}</p>
      </div>
    </div>
    <div :class="['spin-content', { 'spin-blur': spinning }]">
      <slot></slot>
    </div>
  </div>
</template>
<style lang="less" scoped>
.m-spin-wrap {
  position: relative;
  height: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  .m-spin {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9;
    .m-spin-box {
      text-align: center;
      line-height: 0;
      .m-loading-dot {
        position: relative;
        display: inline-block;
        transform: rotate(45deg);
        animation: loading-dot 1.2s linear infinite;
        -webkit-animation: loading-dot 1.2s linear infinite;
        @keyframes loading-dot {
          100% {
            transform: rotate(405deg);
          }
        }
        .dot-item {
          // 单个圆点样式
          position: absolute;
          background: var(--color);
          border-radius: 50%;
          opacity: 0.3;
          animation: loading-dot-color 1s linear infinite alternate;
          -webkit-animation: loading-dot-color 1s linear infinite alternate;
          @keyframes loading-dot-color {
            100% {
              opacity: 1;
            }
          }
        }
        .dot-item:first-child {
          top: 0;
          left: 0;
        }
        .dot-item:nth-child(2) {
          top: 0;
          right: 0;
          animation-delay: 0.4s;
          -webkit-animation-delay: 0.4s;
        }
        .dot-item:nth-child(3) {
          bottom: 0;
          right: 0;
          animation-delay: 0.8s;
          -webkit-animation-delay: 0.8s;
        }
        .dot-item:last-child {
          bottom: 0;
          left: 0;
          animation-delay: 1.2s;
          -webkit-animation-delay: 1.2s;
        }
      }
      .spin-box-rotate {
        animation: spin-circle 2.4s ease-in-out;
        -webkit-animation: spin-circle 2.4s ease-in-out;
      }
      .spin-wrap-box {
        text-align: center;
        line-height: 0;
        position: relative;
        .m-spin-dot {
          position: relative;
          display: inline-block;
          .spin-item {
            position: absolute;
            background: var(--color);
            border-radius: 50%;
          }
          .spin-item:first-child {
            top: 0;
            left: 0;
            opacity: 0.3;
            animation: spin-color-1 var(--speed) linear infinite;
            -webkit-animation: spin-color-1 var(--speed) linear infinite;
          }
          .spin-item:nth-child(2) {
            top: 0;
            right: 0;
            opacity: 0.5;
            animation: spin-color-3 var(--speed) linear infinite;
            -webkit-animation: spin-color-3 var(--speed) linear infinite;
          }
          .spin-item:nth-child(3) {
            bottom: 0;
            right: 0;
            opacity: 0.7;
            animation: spin-color-5 var(--speed) linear infinite;
            -webkit-animation: spin-color-5 var(--speed) linear infinite;
          }
          .spin-item:last-child {
            bottom: 0;
            left: 0;
            opacity: 0.9;
            animation: spin-color-7 var(--speed) linear infinite;
            -webkit-animation: spin-color-7 var(--speed) linear infinite;
          }
        }
        .m-spin-line {
          position: relative;
          display: inline-block;
          .spin-item {
            position: absolute;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            background-color: var(--color);
          }
          .spin-item:first-child {
            opacity: 0.3;
            animation: spin-color-1 var(--speed) linear infinite;
            -webkit-animation: spin-color-1 var(--speed) linear infinite;
          }
          .spin-item:nth-child(2) {
            opacity: 0.5;
            transform: translateX(-50%) rotate(90deg);
            animation: spin-color-3 var(--speed) linear infinite;
            -webkit-animation: spin-color-3 var(--speed) linear infinite;
          }
          .spin-item:nth-child(3) {
            opacity: 0.7;
            transform: translateX(-50%) rotate(180deg);
            animation: spin-color-5 var(--speed) linear infinite;
            -webkit-animation: spin-color-5 var(--speed) linear infinite;
          }
          .spin-item:last-child {
            opacity: 0.9;
            transform: translateX(-50%) rotate(270deg);
            animation: spin-color-7 var(--speed) linear infinite;
            -webkit-animation: spin-color-7 var(--speed) linear infinite;
          }
        }
        .spin-rotate {
          position: absolute;
          left: 0;
          transform: rotate(45deg);
          .spin-item:first-child {
            opacity: 0.4;
            animation: spin-color-2 var(--speed) linear infinite;
            -webkit-animation: spin-color-2 var(--speed) linear infinite;
          }
          .spin-item:nth-child(2) {
            opacity: 0.6;
            animation: spin-color-4 var(--speed) linear infinite;
            -webkit-animation: spin-color-4 var(--speed) linear infinite;
          }
          .spin-item:nth-child(3) {
            opacity: 0.8;
            animation: spin-color-6 var(--speed) linear infinite;
            -webkit-animation: spin-color-6 var(--speed) linear infinite;
          }
          .spin-item:last-child {
            opacity: 1;
            animation: spin-color-8 var(--speed) linear infinite;
            -webkit-animation: spin-color-8 var(--speed) linear infinite;
          }
        }
        .has-tip {
          left: 50%;
          transform: translateX(-50%) rotate(45deg);
        }
        @keyframes spin-color-1 {
          0% {
            opacity: 0.3;
          }
          14.3% {
            opacity: 1;
          }
          100% {
            opacity: 0.4;
          }
        }
        @keyframes spin-color-2 {
          0% {
            opacity: 0.4;
          }
          14.3% {
            opacity: 0.3;
          }
          28.6% {
            opacity: 1;
          }
          100% {
            opacity: 0.5;
          }
        }
        @keyframes spin-color-3 {
          0% {
            opacity: 0.5;
          }
          28.6% {
            opacity: 0.3;
          }
          42.8% {
            opacity: 1;
          }
          100% {
            opacity: 0.6;
          }
        }
        @keyframes spin-color-4 {
          0% {
            opacity: 0.6;
          }
          42.8% {
            opacity: 0.3;
          }
          57.1% {
            opacity: 1;
          }
          100% {
            opacity: 0.7;
          }
        }
        @keyframes spin-color-5 {
          0% {
            opacity: 0.7;
          }
          57.1% {
            opacity: 0.3;
          }
          71.4% {
            opacity: 1;
          }
          100% {
            opacity: 0.8;
          }
        }
        @keyframes spin-color-6 {
          0% {
            opacity: 0.8;
          }
          71.4% {
            opacity: 0.3;
          }
          85.7% {
            opacity: 1;
          }
          100% {
            opacity: 0.9;
          }
        }
        @keyframes spin-color-7 {
          0% {
            opacity: 0.9;
          }
          85.7% {
            opacity: 0.3;
          }
          100% {
            opacity: 1;
          }
        }
        @keyframes spin-color-8 {
          0% {
            opacity: 1;
          }
          100% {
            opacity: 0.3;
          }
        }
      }
      .m-ring-circle,
      .m-ring-rail {
        display: inline-block;
        overflow: hidden;
        animation: spin-circle 0.8s linear infinite;
        -webkit-animation: spin-circle 0.8s linear infinite;
      }
      .circle {
        .trail {
          stroke-width: var(--spin-circle-width);
          stroke-dashoffset: 0;
        }
        .path {
          stroke: var(--color);
          stroke-width: var(--spin-circle-width);
          stroke-dashoffset: 0;
        }
      }
      .m-dynamic-circle {
        display: inline-block;
        animation: spin-circle 2s linear infinite;
        -webkit-animation: spin-circle 2s linear infinite;
        .circle {
          .path {
            stroke-width: 5;
            stroke-dasharray: 90, 150;
            stroke-dashoffset: 0;
            stroke: var(--color);
            stroke-linecap: round;
            animation: loading-dash 1.5s ease-in-out infinite;
            -webkit-animation: loading-dash 1.5s ease-in-out infinite;
            @keyframes loading-dash {
              0% {
                stroke-dasharray: 1, 200;
                stroke-dashoffset: 0;
              }
              50% {
                stroke-dasharray: 90, 150;
                stroke-dashoffset: -40px;
              }
              100% {
                stroke-dasharray: 90, 150;
                stroke-dashoffset: -124px;
              }
            }
          }
        }
      }
      @keyframes spin-circle {
        100% {
          transform: rotate(360deg);
        }
      }
      .m-magic-ring {
        display: inline-block;
        position: relative;
        transform: rotate(45deg);
        animation: spin-rotate 2.5s linear infinite;
        -webkit-animation: spin-rotate 2.5s linear infinite;
        @keyframes spin-rotate {
          100% {
            transform: rotate(405deg);
          }
        }
        .outer-ring {
          position: absolute;
          width: 100%;
          height: 100%;
          border-style: solid;
          border-color: var(--color);
          border-radius: 50%;
          animation: spin-outer-ring 1.5s linear infinite;
          -webkit-animation: spin-outer-ring 1.5s linear infinite;
          @keyframes spin-outer-ring {
            100% {
              transform: rotateY(360deg);
            }
          }
        }
        .inner-ring {
          position: absolute;
          border-style: solid;
          border-color: var(--magic-ring-color);
          border-radius: 50%;
          animation: spin-inner-ring 1.5s linear infinite;
          -webkit-animation: spin-inner-ring 1.5s linear infinite;
          @keyframes spin-inner-ring {
            0% {
              transform: rotateY(45deg);
            }
            100% {
              transform: rotateY(405deg);
            }
          }
        }
      }
      .spin-tip {
        color: var(--color);
        text-align: center;
      }
    }
  }
  .spin-content {
    width: 100%;
    height: 100%;
    transition: opacity 0.3s;
  }
  .spin-blur {
    opacity: 0.5;
    user-select: none;
    pointer-events: none;
  }
}
.spin-small {
  .m-spin .m-spin-box {
    .m-loading-dot {
      width: 20px;
      height: 20px;
      .dot-item {
        width: 8px;
        height: 8px;
      }
    }
    .m-spin-dot {
      width: 20px;
      height: 20px;
      .spin-item {
        width: 6px;
        height: 6px;
      }
    }
    .m-spin-line {
      --line-length: 8px;
      width: calc(var(--line-length) * 3);
      height: calc(var(--line-length) * 3);
      .spin-item {
        transform-origin: 50% calc(var(--line-length) * 1.5);
        border-radius: var(--line-length);
        width: calc(var(--line-length) / 2.5);
        height: var(--line-length);
      }
    }
    .m-ring-circle,
    .m-ring-rail {
      width: 24px;
      height: 24px;
    }
    .m-dynamic-circle {
      width: 26px;
      height: 26px;
    }
    .m-magic-ring {
      width: 24px;
      height: 24px;
      .outer-ring,
      .inner-ring {
        border-width: 3px;
      }
      .inner-ring {
        top: 3px;
        left: 3px;
        width: calc(100% - 6px);
        height: calc(100% - 6px);
      }
    }
    .spin-tip {
      font-size: 14px;
      font-weight: 400;
      line-height: 16px;
      margin-top: 6px;
    }
  }
}
.spin-middle {
  .m-spin .m-spin-box {
    .m-loading-dot {
      width: 30px;
      height: 30px;
      .dot-item {
        width: 11px;
        height: 11px;
      }
    }
    .m-spin-dot {
      width: 30px;
      height: 30px;
      .spin-item {
        width: 9px;
        height: 9px;
      }
    }
    .m-spin-line {
      --line-length: 12px;
      width: calc(var(--line-length) * 3);
      height: calc(var(--line-length) * 3);
      .spin-item {
        transform-origin: 50% calc(var(--line-length) * 1.5);
        border-radius: var(--line-length);
        width: calc(var(--line-length) / 3);
        height: var(--line-length);
      }
    }
    .m-ring-circle,
    .m-ring-rail {
      width: 36px;
      height: 36px;
    }
    .m-dynamic-circle {
      width: 38px;
      height: 38px;
    }
    .m-magic-ring {
      width: 36px;
      height: 36px;
      .outer-ring,
      .inner-ring {
        border-width: 5px;
      }
      .inner-ring {
        top: 5px;
        left: 5px;
        width: calc(100% - 10px);
        height: calc(100% - 10px);
      }
    }
    .spin-tip {
      font-size: 14px;
      font-weight: 500;
      line-height: 18px;
      margin-top: 10px;
    }
  }
}
.spin-large {
  .m-spin .m-spin-box {
    .m-loading-dot {
      width: 40px;
      height: 40px;
      .dot-item {
        width: 15px;
        height: 15px;
      }
    }
    .m-spin-dot {
      width: 40px;
      height: 40px;
      .spin-item {
        width: 12px;
        height: 12px;
      }
    }
    .m-spin-line {
      --line-length: 16px;
      width: calc(var(--line-length) * 3);
      height: calc(var(--line-length) * 3);
      .spin-item {
        transform-origin: 50% calc(var(--line-length) * 1.5);
        border-radius: var(--line-length);
        width: calc(var(--line-length) / 3);
        height: var(--line-length);
      }
    }
    .m-ring-circle,
    .m-ring-rail {
      width: 48px;
      height: 48px;
    }
    .m-dynamic-circle {
      width: 50px;
      height: 50px;
    }
    .m-magic-ring {
      width: 48px;
      height: 48px;
      .outer-ring,
      .inner-ring {
        border-width: 6px;
      }
      .inner-ring {
        top: 6px;
        left: 6px;
        width: calc(100% - 12px);
        height: calc(100% - 12px);
      }
    }
    .spin-tip {
      font-size: 16px;
      font-weight: 500;
      line-height: 20px;
      margin-top: 14px;
    }
  }
}
</style>

②在要使用的页面引入:

<script setup lang="ts">
import Spin from './Spin.vue'
import { ref } from 'vue'
const spinning = ref(true)
</script>
<template>
  <div>
    <h1>{
  
  { $route.name }} {
  
  { $route.meta.title }}</h1>
    <h2 class="mt30 mb10">基本使用</h2>
    <Flex align="center"> Loading state:<Switch v-model="spinning" /> </Flex>
    <br />
    <Spin style="width: 800px" :spinning="spinning">
      <p class="spin-content">
        当 spinning 为 false 时,不显示 loading 状态;当 spinning 为 true 时,显示 loading 效果;如果不设置 tip
        描述文案时,则只有 loading 效果水平垂直居中;如果设置了 tip 描述文案,则 loading 效果和 tip
        描述文案一起水平垂直居中。
      </p>
    </Spin>
    <h2 class="mt30 mb10">旋转的点</h2>
    <Spin style="width: 800px" :spinning="spinning" indicator="spin-dot">
      <p class="spin-content">
        当 spinning 为 false 时,不显示 loading 状态;当 spinning 为 true 时,显示 loading 效果;如果不设置 tip
        描述文案时,则只有 loading 效果水平垂直居中;如果设置了 tip 描述文案,则 loading 效果和 tip
        描述文案一起水平垂直居中。
      </p>
    </Spin>
    <h2 class="mt30 mb10">旋转的线</h2>
    <Spin style="width: 800px" :spinning="spinning" indicator="spin-line">
      <p class="spin-content">
        当 spinning 为 false 时,不显示 loading 状态;当 spinning 为 true 时,显示 loading 效果;如果不设置 tip
        描述文案时,则只有 loading 效果水平垂直居中;如果设置了 tip 描述文案,则 loading 效果和 tip
        描述文案一起水平垂直居中。
      </p>
    </Spin>
    <h2 class="mt30 mb10">圆环指示符</h2>
    <Spin style="width: 800px" :spinning="spinning" indicator="ring-circle">
      <p class="spin-content">
        当 spinning 为 false 时,不显示 loading 状态;当 spinning 为 true 时,显示 loading 效果;如果不设置 tip
        描述文案时,则只有 loading 效果水平垂直居中;如果设置了 tip 描述文案,则 loading 效果和 tip
        描述文案一起水平垂直居中。
      </p>
    </Spin>
    <h2 class="mt30 mb10">圆环轨道指示符</h2>
    <Spin style="width: 800px" :spinning="spinning" indicator="ring-rail">
      <p class="spin-content">
        当 spinning 为 false 时,不显示 loading 状态;当 spinning 为 true 时,显示 loading 效果;如果不设置 tip
        描述文案时,则只有 loading 效果水平垂直居中;如果设置了 tip 描述文案,则 loading 效果和 tip
        描述文案一起水平垂直居中。
      </p>
    </Spin>
    <h2 class="mt30 mb10">动态圆环指示符</h2>
    <Spin style="width: 800px" :spinning="spinning" indicator="dynamic-circle">
      <p class="spin-content">
        当 spinning 为 false 时,不显示 loading 状态;当 spinning 为 true 时,显示 loading 效果;如果不设置 tip
        描述文案时,则只有 loading 效果水平垂直居中;如果设置了 tip 描述文案,则 loading 效果和 tip
        描述文案一起水平垂直居中。
      </p>
    </Spin>
    <h2 class="mt30 mb10">双圆环指示符</h2>
    <Spin style="width: 800px" :spinning="spinning" indicator="magic-ring">
      <p class="spin-content">
        当 spinning 为 false 时,不显示 loading 状态;当 spinning 为 true 时,显示 loading 效果;如果不设置 tip
        描述文案时,则只有 loading 效果水平垂直居中;如果设置了 tip 描述文案,则 loading 效果和 tip
        描述文案一起水平垂直居中。
      </p>
    </Spin>
    <h2 class="mt30 mb10">自定义描述文案</h2>
    <Space>
      <Spin class="u-spin" tip="加载中..." :spinning="spinning" />
      <Spin class="u-spin" tip="加载中..." :spinning="spinning" indicator="spin-dot" />
      <Spin class="u-spin" tip="加载中..." :spinning="spinning" indicator="spin-line" />
      <Spin class="u-spin" tip="加载中..." :spinning="spinning" indicator="ring-circle" />
      <Spin class="u-spin" tip="加载中..." :spinning="spinning" indicator="ring-rail" />
      <Spin class="u-spin" tip="加载中..." :spinning="spinning" indicator="dynamic-circle" />
      <Spin class="u-spin" tip="加载中..." :spinning="spinning" indicator="magic-ring" />
    </Space>
    <h2 class="mt30 mb10">自定义样式</h2>
    <Space>
      <Spin class="u-spin" color="#fadb14" :spinning="spinning" />
      <Spin class="u-spin" color="#fadb14" :spinning="spinning" indicator="spin-dot" />
      <Spin class="u-spin" color="#fadb14" :spinning="spinning" indicator="spin-line" />
      <Spin class="u-spin" color="#fadb14" :spinning="spinning" :ring-circle-percent="50" indicator="ring-circle" />
      <Spin
        class="u-spin"
        color="#fadb14"
        :ring-circle-percent="50"
        ring-rail-color="rgba(212, 136, 6, 0.6)"
        :spinning="spinning"
        indicator="ring-rail"
      />
      <Spin class="u-spin" color="#fadb14" :spinning="spinning" indicator="dynamic-circle" />
      <Spin class="u-spin" color="#fadb14" magic-ring-color="#ffe58f" :spinning="spinning" indicator="magic-ring" />
    </Space>
    <h2 class="mt30 mb10">各种大小</h2>
    <Space vertical>
      <Space>
        <Spin class="u-size-spin" :spinning="spinning" size="small" />
        <Spin class="u-size-spin" :spinning="spinning" />
        <Spin class="u-size-spin" :spinning="spinning" size="large" />
        <Spin class="u-size-spin" :spinning="spinning" size="small" indicator="spin-dot" />
        <Spin class="u-size-spin" :spinning="spinning" indicator="spin-dot" />
        <Spin class="u-size-spin" :spinning="spinning" size="large" indicator="spin-dot" />
        <Spin class="u-size-spin" :spinning="spinning" size="small" indicator="spin-line" />
        <Spin class="u-size-spin" :spinning="spinning" indicator="spin-line" />
        <Spin class="u-size-spin" :spinning="spinning" size="large" indicator="spin-line" />
      </Space>
      <Space>
        <Spin class="u-size-spin" :spinning="spinning" size="small" indicator="ring-circle" />
        <Spin class="u-size-spin" :spinning="spinning" indicator="ring-circle" />
        <Spin class="u-size-spin" :spinning="spinning" size="large" indicator="ring-circle" />
        <Spin class="u-size-spin" :spinning="spinning" size="small" indicator="ring-rail" />
        <Spin class="u-size-spin" :spinning="spinning" indicator="ring-rail" />
        <Spin class="u-size-spin" :spinning="spinning" size="large" indicator="ring-rail" />
        <Spin class="u-size-spin" :spinning="spinning" size="small" indicator="dynamic-circle" />
        <Spin class="u-size-spin" :spinning="spinning" indicator="dynamic-circle" />
        <Spin class="u-size-spin" :spinning="spinning" size="large" indicator="dynamic-circle" />
      </Space>
      <Space>
        <Spin class="u-size-spin" :spinning="spinning" size="small" indicator="magic-ring" />
        <Spin class="u-size-spin" :spinning="spinning" indicator="magic-ring" />
        <Spin class="u-size-spin" :spinning="spinning" size="large" indicator="magic-ring" />
      </Space>
    </Space>
  </div>
</template>
<style lang="less" scoped>
.spin-content {
  display: inline-block;
  border: 1px solid #91d5ff;
  background-color: #e6f7ff;
  padding: 30px;
}
.u-spin {
  width: 100px;
  height: 100px;
}
.u-size-spin {
  width: 80px;
  height: 80px;
}
</style>
相关文章
|
7天前
|
缓存 监控 UED
升级 Vue3 时,如何减少打包体积的增加?
升级 Vue3 时,如何减少打包体积的增加?
86 59
|
6天前
|
JavaScript
在vue3中(vite)引入unocss,安装配置unocss
在vue3中(vite)引入unocss,安装配置unocss
|
7天前
|
API UED
升级 Vue3 后,项目的打包体积会有什么变化?
升级 Vue3 后,项目的打包体积会有什么变化?
94 57
|
8天前
|
缓存 JavaScript 前端开发
「offer来了」从基础到进阶原理,从vue2到vue3,48个知识点保姆级带你巩固vuejs知识体系
该文章全面覆盖了Vue.js从基础知识到进阶原理的48个核心知识点,包括Vue CLI项目结构、组件生命周期、响应式原理、Composition API的使用等内容,并针对Vue 2与Vue 3的不同特性进行了详细对比与讲解。
「offer来了」从基础到进阶原理,从vue2到vue3,48个知识点保姆级带你巩固vuejs知识体系
|
7天前
|
API UED
如何实现Vue2项目升级Vue3?
如何实现Vue2项目升级Vue3?
16 1
|
9天前
|
JavaScript 前端开发 API
vue3的传送门teleport究竟有多神奇?suspense发起异步请求有多简约?
该文章介绍了Vue3中新特性Teleport和Suspense的使用方法,演示了如何使用Teleport进行DOM节点的非父子关系传送,以及Suspense在处理异步组件加载时的优雅展示和错误处理技巧。
|
9天前
|
JavaScript
particles 粒子背景插件在vue3中的使用
本文介绍了如何在Vue 3项目中使用`particles.vue3`库来创建粒子背景特效。文章提供了粒子背景插件的概述、安装步骤、配置参数说明,并展示了粒子特效的实现效果。同时,提供了在main.js中进行全局配置、在Vue组件中使用粒子背景组件的示例代码,以及完整代码的下载链接。
|
8天前
|
JavaScript API
再不学vue3就没有人要你了!速来围观vue3
这篇技术文章介绍了作者从最初对学习 Vue3 抵触到最终决定投入学习的心路历程,展示了 Vue3 相较于 Vue2 的诸多改进和新特性,如更优的性能、更小的代码体积及更佳的 TypeScript 支持。文章重点阐述了 Vue3 中 createApp 的使用变化、emits 机制、多事件处理、Fragment 的引入等重要功能升级。此外,还深入探讨了 Composition API 和 Options API 的区别,强调 Composition API 在代码组织和逻辑复用方面的优势,并给出了在不同项目规模中选择合适 API 的建议。
21 0
|
9天前
|
JavaScript 前端开发 UED
组件库实战 | 用vue3+ts实现全局Header和列表数据渲染ColumnList
该文章详细介绍了如何使用Vue3结合TypeScript来开发全局Header组件和列表数据渲染组件ColumnList,并提供了从设计到实现的完整步骤指导。
|
9天前
|
JavaScript API
模块化妙用!用vue3实现一个鼠标追踪器和异步加载组件
该文章展示了如何使用Vue3的Composition API实现鼠标追踪器功能,并介绍了创建异步加载组件的方法,利用TS泛型增强了组件的灵活性与可维护性。
下一篇
无影云桌面