美文网首页
Vue组件开发系列之badge组件

Vue组件开发系列之badge组件

作者: vue爱好者 | 来源:发表于2018-10-30 13:43 被阅读167次

组件源码:
https://github.com/AntJavascript/widgetUI/tree/master/badge

FireShot Capture 8 - nvx - http___localhost_8080_demo#_badge.png

组件结构:

<template>
    <div class="wt-badge" :class="type">
        {{title}}
    </div>
</template>

代码分析:

props参数:

props: {
    title: { // 组件显示的文字 (可选)
      type: String | Number, 
      default: () => {
        return '';
      }
    },
    type: { // (可选)主要是背景色的不同(可选值:"primary", "default")
      type: String,
      default: () => {
        return 'default';
      }
    }
  }

css代码:

.wt-badge {
    padding: 0.3rem;
    display: inline-block;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 0.6rem;
    min-width: 0.6rem;
    min-height: 0.6rem;
    box-sizing: border-box;
    line-height: 0.4rem;
    text-align: center;
    &.default {
        background: #ef4f4f;
    }
    &.primary {
        background: #1BB5F1;
    }
  }

相关文章

网友评论

      本文标题:Vue组件开发系列之badge组件

      本文链接:https://www.haomeiwen.com/subject/qfxgtqtx.html