首页 > 其他分享 >vue 封装带图标的标题组件

vue 封装带图标的标题组件

时间:2022-10-28 17:46:17浏览次数:46  
标签:vue 封装 center item rem font com 图标

效果图: 

com-item-title.vue组件

<template>
  <div class="com-item-title">
    <div class="com-item-box flex-center-center">
      <div class="com-item-cont">
        <div class="cn" v-html="titleCn"></div>
        <div class="en" v-html="titleEn"></div>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  data() {
    return {};
  },
  props: {
    titleCn: {
      type: String,
    },
    titleEn: {
      type: String,
    },
  },
 
  methods: {},
};
</script>
 
<style  scoped>
//1rem=100px,可自行转为px
.flex-center-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
  .com-item-cont {
    text-align: center;
    position: relative;
  }
  .com-item-cont::before {
    width: 0.76rem;
    height: 0.76rem;
    display: block;
    content: "";
    background: url("https://eventimg.oss-cn-shenzhen.aliyuncs.com/jintuoluo/2022/pc/small_ball_img.png")
      no-repeat;
    background-size: 100% 100%;
    position: absolute;
    left: -0.86rem;
    top: -0.22rem;//左边球的球的上下位置
  }
  .com-item-cont::after {
    width: 0.76rem;
    height: 0.76rem;
    display: block;
    content: "";
    background: url("https://eventimg.oss-cn-shenzhen.aliyuncs.com/jintuoluo/2022/pc/small_ball_img.png")
      no-repeat;
    background-size: 100% 100%;
    position: absolute;
    right: -0.86rem;
    top: 1.6em;//右边球的球的上下位置
  }
  .cn {
    font-size: 0.6rem;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 300;
    color: #092e6d;
    line-height: 0.6rem;
  }
  .en {
    font-size: 0.21rem;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 400;
    color: #adbac7;
    line-height: 0.31rem;
    margin-top: 0.16rem;
  }
 
</style>

about-fbec2022.vue页面引用com-item-title.vue组件

<template>
  <!-- 首页-大会介绍 -->
  <div class="about-fbec2022">
    <comItemTitle titleCn="FBEC2022" titleEn="About FBEC2022"></comItemTitle>
    
  </div>
</template>
<script>
import comItemTitle from "@/components/common/com-item-title.vue";
 
export default {
  name: "about-fbec2022",
  
  components: {
    comItemTitle,
  },
  data() {
    return {
      
    };
  },
 
};
</script>

 

标签:vue,封装,center,item,rem,font,com,图标
From: https://www.cnblogs.com/lengfang/p/16836881.html

相关文章

  • QT设置窗口图标
    点击项目,添加新文件选择Qt,选择qtresourcefile点击choose,填写Filename文件名点击下一步,添加到项目,添加到版本控制系统Git,点击完成添加前缀AddPrefix点击添加AddFiles,图......
  • vuex和浏览器【sessionStorage,localStorage ..】 得区别
    1.Vuex的主要作用是用来共享和管理数据,那为什么不直接使用浏览器缓存呢?2.Vuex和浏览器缓存策略的根本区别是什么?3.Vuex,state仓库中的数据流是单向同步的,那为什么可以在act......
  • vue中的计算属性
    <!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><metahttp-e......
  • 16_Vue列表渲染中key的工作原理和虚拟DOM对比算法
    key的作用粗略的讲,key的作用就是给节点设置一个唯一的标识就像我们人类社会中,每个人的身份证号一样在大部分对key要求不是很严格的场景下,使用index作为key是没问......
  • 13_Vue中的计算属性
    需求两个输入框下方一个全名要求输入框内容发生变化的时候,全名也跟着变化用计算属性很快能写出来,我们先用插值语法和methods配置项完成methods和插值语法方法1使......
  • uniapp开发使用 web-view APP 与 H5 (vue)通信
    需求:这边是uniapp开发的APP 需要内嵌H5(vue),就得使用web-view跳转网页H5端在vue的index,html文件引入web-view的插件<scripttype="text/javascript"src="https://js......
  • 14_Vue监视属性
    顾名思义,监视一个属性的变化需求按照之前案例,isHot的值发生改动的时候我需要知道这件事,isHot发生改变,就需要通知我watchkey值:你想监视的属性名(data配置项中的isHot......
  • js对象封装 Json字符
    不废话直接上代码:functionobjUserNickName(UserName,NickName){this.UserName=UserName;this.NickName=NickName;}objuser1=newobjUserNickName();objuser......
  • 创建使用Ant的vue项目时遇到的问题
    一、成功运行后vue版本   二、创建中遇到的问题    1、开始创建项目时,vue、ant、webpack(8.15.0)都是高版本,ant1.7.8版本的代码不能适用(需求为:学习ant1.......
  • Hutool工具-TreeUtil封装树形结构数据,你用过了吗
    在开发过程中,必定会遇到树形结构的数据,一般都是后端直接从库里查询出来然后自定义方法去封装成树形树形返回给前端。其实Hutool工具类也提供了这个方法,这种方式使用起来也......