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>
相关文章
|
16天前
|
存储 JavaScript 前端开发
vue3的脚手架模板你真的了解吗?里面有很多值得我们学习的地方!
【10月更文挑战第21天】 vue3的脚手架模板你真的了解吗?里面有很多值得我们学习的地方!
vue3的脚手架模板你真的了解吗?里面有很多值得我们学习的地方!
|
13天前
|
JavaScript 前端开发 开发者
Vue 3中的Proxy
【10月更文挑战第23天】Vue 3中的`Proxy`为响应式系统带来了更强大、更灵活的功能,解决了Vue 2中响应式系统的一些局限性,同时在性能方面也有一定的提升,为开发者提供了更好的开发体验和性能保障。
30 7
|
14天前
|
前端开发 数据库
芋道框架审批流如何实现(Cloud+Vue3)
芋道框架审批流如何实现(Cloud+Vue3)
36 3
|
13天前
|
JavaScript 数据管理 Java
在 Vue 3 中使用 Proxy 实现数据双向绑定的性能如何?
【10月更文挑战第23天】Vue 3中使用Proxy实现数据双向绑定在多个方面都带来了性能的提升,从更高效的响应式追踪、更好的初始化性能、对数组操作的优化到更优的内存管理等,使得Vue 3在处理复杂的应用场景和大量数据时能够更加高效和稳定地运行。
34 1
|
13天前
|
JavaScript 开发者
在 Vue 3 中使用 Proxy 实现数据的双向绑定
【10月更文挑战第23天】Vue 3利用 `Proxy` 实现了数据的双向绑定,无论是使用内置的指令如 `v-model`,还是通过自定义事件或自定义指令,都能够方便地实现数据与视图之间的双向交互,满足不同场景下的开发需求。
34 1
|
15天前
|
前端开发 JavaScript
简记 Vue3(一)—— setup、ref、reactive、toRefs、toRef
简记 Vue3(一)—— setup、ref、reactive、toRefs、toRef
|
16天前
Vue3 项目的 setup 函数
【10月更文挑战第23天】setup` 函数是 Vue3 中非常重要的一个概念,掌握它的使用方法对于开发高效、灵活的 Vue3 组件至关重要。通过不断的实践和探索,你将能够更好地利用 `setup` 函数来构建优秀的 Vue3 项目。
|
19天前
|
JavaScript API
vue3知识点:ref函数
vue3知识点:ref函数
29 2
|
19天前
|
API
vue3知识点:reactive函数
vue3知识点:reactive函数
24 1
|
19天前
|
JavaScript 前端开发 API
vue3知识点:Vue3.0中的响应式原理和 vue2.x的响应式
vue3知识点:Vue3.0中的响应式原理和 vue2.x的响应式
23 0