最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于Vue2實(shí)現(xiàn)印章徽章組件

 更新時(shí)間:2023年10月30日 15:34:50   作者:飛仔FeiZai  
這篇文章主要介紹了如何基于vue2實(shí)現(xiàn)簡單的印章徽章控件,文中通過示例代碼講解詳細(xì),具有一定的學(xué)習(xí)價(jià)值,需要的朋友們下面就跟隨小編來一起學(xué)習(xí)學(xué)習(xí)吧

Vue2 實(shí)現(xiàn)印章徽章組件

需要實(shí)現(xiàn)的組件效果:

該組件有設(shè)置顏色、大小、旋轉(zhuǎn)度數(shù)和文本內(nèi)容功能。

組件實(shí)現(xiàn)代碼

<template>
  <div
    class="first-ring"
    v-bind="getBindValue"
    :class="getStampBadgeClass"
    :style="{ transform: `rotate(${rotate}deg)` }"
  >
    <div class="second-ring" :class="getStampBadgeClass">
      <div class="third-ring" :class="getStampBadgeClass">
        <div class="forth-ring" :class="getStampBadgeClass">
          <div class="content-rectangle ellipsis" :class="getStampBadgeClass">
            <span class="">{{ content }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "StampBadge",
    // inheritAttrs: false,
    props: {
      color: {
        type: String,
        default: "primary",
        validator: (v) =>
          ["primary", "error", "warning", "success", "info"].includes(v),
      },
      /**
       * stamp badge size.
       * @default: middle
       */
      size: {
        type: String,
        default: "middle",
        validator: (v) => ["large", "middle", "small"].includes(v),
      },
      /**
       * stamp badge rotate deg.
       * @default: 0
       */
      rotate: { type: Number, default: 0 },
      content: { type: String, default: "Unknown" },
    },
    computed: {
      getStampBadgeClass() {
        const { color, size } = this.$props;
        return [
          {
            [`stamp-badge-${color}`]: !!color,
            [`stamp-badge-${size}`]: !!size,
          },
        ];
      },
      getBindValue() {
        return { ...this.$attrs, ...this.$props };
      },
    },
    methods: {},
  };
</script>

<style lang="less" scoped>
  .first-ring {
    border-radius: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .second-ring {
    background: #fff;
    border-radius: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .third-ring {
    border-radius: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .forth-ring {
    background: #fff;
    border-radius: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
  }

  .content-rectangle {
    background: #fff;
    font-weight: bold;
    text-align: center;
    position: absolute;
  }

  .ellipsis {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  // primary
  .stamp-badge-primary.first-ring {
    background: #1890ff;
  }

  .stamp-badge-primary.third-ring {
    background: #1890ff;
  }

  .stamp-badge-primary.content-rectangle {
    border: 1px solid #1890ff;
    color: #1890ff;
  }

  // success
  .stamp-badge-success.first-ring {
    background: #52c41a;
  }

  .stamp-badge-success.third-ring {
    background: #52c41a;
  }

  .stamp-badge-success.content-rectangle {
    border: 1px solid #52c41a;
    color: #52c41a;
  }

  // error
  .stamp-badge-error.first-ring {
    background: #ff4d4f;
  }

  .stamp-badge-error.third-ring {
    background: #ff4d4f;
  }

  .stamp-badge-error.content-rectangle {
    border: 1px solid #ff4d4f;
    color: #ff4d4f;
  }

  // warning
  .stamp-badge-warning.first-ring {
    background: #faad14;
  }

  .stamp-badge-warning.third-ring {
    background: #faad14;
  }

  .stamp-badge-warning.content-rectangle {
    border: 1px solid #faad14;
    color: #faad14;
  }

  // info
  .stamp-badge-info.first-ring {
    background: #ccc;
  }

  .stamp-badge-info.third-ring {
    background: #ccc;
  }

  .stamp-badge-info.content-rectangle {
    border: 1px solid #ccc;
    color: #ccc;
  }

  // large
  .stamp-badge-large.first-ring {
    width: 84px;
    height: 84px;
  }

  .stamp-badge-large.second-ring {
    width: 80px;
    height: 80px;
  }

  .stamp-badge-large.third-ring {
    width: 74px;
    height: 74px;
  }

  .stamp-badge-large.forth-ring {
    width: 64px;
    height: 64px;
  }

  .stamp-badge-large.content-rectangle {
    width: 90px;
    font-size: 1.2rem;
  }

  // middle
  .stamp-badge-middle.first-ring {
    width: 64px;
    height: 64px;
  }

  .stamp-badge-middle.second-ring {
    width: 60px;
    height: 60px;
  }

  .stamp-badge-middle.third-ring {
    width: 56px;
    height: 56px;
  }

  .stamp-badge-middle.forth-ring {
    width: 48px;
    height: 48px;
  }

  .stamp-badge-middle.content-rectangle {
    width: 70px;
    font-size: 1rem;
  }

  // small
  .stamp-badge-small.first-ring {
    width: 54px;
    height: 54px;
  }

  .stamp-badge-small.second-ring {
    width: 50px;
    height: 50px;
  }

  .stamp-badge-small.third-ring {
    width: 46px;
    height: 46px;
  }

  .stamp-badge-small.forth-ring {
    width: 38px;
    height: 38px;
  }

  .stamp-badge-small.content-rectangle {
    width: 60px;
    font-size: 0.8rem;
  }
</style>

組件應(yīng)用代碼

<div style="width: 500px; height: 100px; position: relative">
  <StampBadge
    style="position: absolute; top: 0; right: 0"
    size="middle"
    color="success"
    content="已支付"
    :rotate="45"
  />
</div>

以上就是基于Vue2實(shí)現(xiàn)印章徽章組件的詳細(xì)內(nèi)容,更多關(guān)于Vue2印章徽章組件的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 15分鐘學(xué)會(huì)vue項(xiàng)目改造成SSR(小白教程)

    15分鐘學(xué)會(huì)vue項(xiàng)目改造成SSR(小白教程)

    這篇文章主要介紹了15分鐘學(xué)會(huì)vue項(xiàng)目改造成SSR(小白教程),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-12-12
  • LogicFlow插件使用前準(zhǔn)備詳解

    LogicFlow插件使用前準(zhǔn)備詳解

    這篇文章主要為大家介紹了LogicFlow插件使用前準(zhǔn)備詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-01-01
  • Vue分頁組件實(shí)例代碼

    Vue分頁組件實(shí)例代碼

    這篇文章主要為大家詳細(xì)介紹了Vue分頁組件的實(shí)例代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • Vue仿今日頭條實(shí)例詳解

    Vue仿今日頭條實(shí)例詳解

    這篇文章主要介紹了Vue仿今日頭條實(shí)例詳解,并把相關(guān)代碼做了說明,對(duì)此有興趣的朋友參考下吧。
    2018-02-02
  • vue3與ts組件封裝提高代碼復(fù)用性

    vue3與ts組件封裝提高代碼復(fù)用性

    這篇文章主要為大家介紹了vue3與ts組件封裝提高代碼復(fù)用性示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07
  • vue項(xiàng)目tween方法實(shí)現(xiàn)返回頂部的示例代碼

    vue項(xiàng)目tween方法實(shí)現(xiàn)返回頂部的示例代碼

    這篇文章主要介紹了vue項(xiàng)目tween方法實(shí)現(xiàn)返回頂部,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-03-03
  • uniapp使用scroll-view下拉刷新無法取消的坑及解決

    uniapp使用scroll-view下拉刷新無法取消的坑及解決

    這篇文章主要介紹了uniapp使用scroll-view下拉刷新無法取消的坑及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • 深入了解Vue.js中的Vuex狀態(tài)管理模式

    深入了解Vue.js中的Vuex狀態(tài)管理模式

    Vuex是Vue.js的官方狀態(tài)管理模式,它為Vue.js應(yīng)用程序提供了一個(gè)集中式的狀態(tài)管理解決方案,Vuex可以幫助我們管理應(yīng)用程序中所有組件的狀態(tài),使得狀態(tài)管理變得更加簡單和可靠,需要詳細(xì)了解可以參考下文
    2023-05-05
  • Vue2?Observer實(shí)例dep和閉包中dep區(qū)別詳解

    Vue2?Observer實(shí)例dep和閉包中dep區(qū)別詳解

    這篇文章主要為大家介紹了Vue2?Observer實(shí)例dep和閉包中dep區(qū)別詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-10-10
  • vue?parseHTML?函數(shù)源碼解析

    vue?parseHTML?函數(shù)源碼解析

    這篇文章主要為大家介紹了vue?parseHTML函數(shù)的源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-07-07

最新評(píng)論

延长县| 德保县| 剑河县| 肇庆市| 宜兰市| 南通市| 潮州市| 丹江口市| 定州市| 宿迁市| 乐陵市| 大悟县| 南部县| 商城县| 武城县| 蛟河市| 讷河市| 广河县| 积石山| 吉木乃县| 汝州市| 铁岭市| 叶城县| 旺苍县| 龙岩市| 新竹市| 山丹县| 锦屏县| 麻城市| 嘉善县| 巴里| 都兰县| 武威市| 惠来县| 镶黄旗| 壤塘县| 高邑县| 义乌市| 龙里县| 奎屯市| 滕州市|