阅读背景:

vue组件封装及使用示例_weixin_30907523的博客

来源:互联网 

1)在组件目录中创建公用组件文件,comTitle.vue如下:

//comTitle.vue
<template>
  <div class="title-common">
    <div class="title">
      <span :class="[titleSize]" v-text="title"/>
      <span class="title-sub" v-if="subTitle" v-text="subTitle"/>
    </div>
    <slot></slot>
  </div>
</template>
<script>
export default {
  props: {
    size: {
      type: String,
      default: "normal"
    },
    //标题
    title: {
      type: String,
      required: true
    },
    //小标题说明
    subTitle: {
      type: String,
      default: ""
    }
  },
  computed: {
    titleSize() {
      return `title-${this.size}`;
    }
  }
};
</script>
<style lang="postcss" scoped>
@import url("common.postcss");
.title-common {
  display: flex;
  align-items: center;
  justify-content: space-between;
  & .title {
    display: flex;
    align-items: center;
  }
  & .title-sub {
    font-size: var(--h6);
    color: #363636;
    padding-left: 19px;
  }
  & .title > span:first-child {
    color: #000;
    border-left: 4px solid var(--primaryBlueColor);
    padding-left: 9px;
  }
  & .title-big {
    display: inline-block;
    font-size: 18px;
    line-height: 18px;
    font-weight: 700;
  }
  & .title-normal {
    font-size: var(--h3);
    line-height: var(--h3);
  }
  & .title-small {
    font-size: var(--h3);
    line-height: var(--h3);
    font-weight: 550;
  }
  & .title-mini {
    font-size: var(--h4);
    line-height: var(--h4);
    font-weight: 550;
  }
  & .title-exmini {
    font-size: var(--h6);
    line-height: var(--h6);
    font-weight: 550;
  }
}
</style>
//



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: