vue模仿twitter写一个自己的博客——个人信息栏目

个人信息栏目主要实现一个带下划线的文字组件,很多地方都可以用到。可以设置颜色,字体大小,是否是粗体,下划线的高度
TextUnderline.vue

<template>
  <div ref="wrap">
    <slot name="at"></slot>
    <slot name="icon"></slot>
    <span class="text" ref="text" @click="handleClick">{{text}}</span>
  </div>
</template>
<script lang='ts'>
import { Component, Vue, Watch, Prop } from "vue-property-decorator";
@Component({
  components: {}
})
export default class extends Vue {
  @Prop()
  private text!: string;
  @Prop()
  private color!: string;
  @Prop()
  private size!: string;
  @Prop()
  private isBold!: string;
  @Prop()
  private underlineHeight!: string;
  private mounted() {
    if (this.size) {
      if (!isNaN(Number(this.size))) {
        const obj = this.$refs.wrap as HTMLElement;
        obj.style.fontSize = this.size + "px";
      }
      if (!isNaN(Number(this.underlineHeight))) {
        const obj = this.$refs.text as HTMLElement;
        obj.style.borderWidth = this.underlineHeight + "px";
      }
      if (this.color) {
        const obj = this.$refs.text as HTMLElement;
        obj.style.borderColor = this.color;
        obj.style.color = this.color;
      }
      if (this.isBold && this.isBold === "true") {
        const obj = this.$refs.wrap as HTMLElement;
        obj.style.fontWeight = "bold";
      }
    }
  }
  private handleClick() {
    this.$emit("click");
  }
}
</script>
<style scoped lang="scss">
div {
  font-size: 20px;
  .text:hover {
    border-bottom: 2px solid black;
    padding-bottom: 1px;
    cursor: pointer;
  }
}
</style>

效果展示

在这里插入图片描述

项目地址

https://github.com/pppercyWang/twitter-blog-vue

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 基于Vue的一些资料 内容 UI组件 开发框架 实用库 服务端 辅助工具 应用实例 Demo示例 element★...
    尝了又尝阅读 4,930评论 0 1
  • 简说Vue (组件库) https://github.com/ElemeFE/element" 饿了么出品的VUE...
    Estrus丶阅读 5,786评论 0 1
  • UI组件 element- 饿了么出品的Vue2的web UI工具套件 Vux- 基于Vue和WeUI的组件库 m...
    小姜先森o0O阅读 13,339评论 0 72
  • 世界上最大的牢笼 是肉体 它是撕不下的标签 毁不了的容器 这具肉体 从蹒跚学步 到白发稀稀 替代着你 灵魂和脾气 ...
    花花的樱花阅读 3,471评论 1 6
  • 2018.4.16 半夜 觉得自己的生活为什么总是差一块。心理空空的。表面是好的,内心还是缺什么。 半夜突然又醒了...
    行靜阅读 1,801评论 0 0

友情链接更多精彩内容