VUE-33 循环不同样式

本节:循环内容没问题,那么怎么循环内容里,不同的样式?

1.循环输出数据。重点:定义冒号,属性变成变量,可以循环不同的内容

2.循环的数据

3.定义变量的样式 

 完整代码:

<template>
  <div class="container">
    <div class="out">
      <!-- 保证不换行 -->
      <div>
        <div class="top">
          <!-- 头部图片 -->
          <div class="img11">
            <img class="img1" src="../../../public/image/promotionActivity/img1.png" alt="" />
          </div>
          <!--5G最新活动 -->
          <div class="topText">
            <div style="display: flex">
              <div class="mostActivity">5G最新活动</div>
              <div class="limitYouHui1">
                <div class="limitYouHuiFont">限时特惠</div>
              </div>
            </div>
            <div class="MessageService1">
              <div class="MessageService"
                >短信服务(Short Message
                Service)是广大企业客户快速触达手机用户所优选使用的通信能力。调用API或用群发助手,即可发送验证码、通知类和营销类短信;国内验证短信秒级触达,到达率最高可达99%;</div
              >
            </div>
            <div class="iconContext">
              <div class="icon1"> <img src="../../../public/image/promotionActivity/icon1.png" alt="" /></div>
              <div class="day">2021/10/01 ~ 2021/12/01</div>
            </div>

            <div class="button">
              <div class="buttonFont">参加活动</div>
            </div>
          </div>
        </div>
        <!-- 活动详情 -->
        <div class="xianqing">活动详情 </div>

        <!-- 线 -->
        <div class="line">
          <div class="lineBlue"></div>
          <div class="lineLong"></div>
        </div>
        <div>
          <div class="messageServiceContent"
            >短信服务(Short Message
            Service)是广大企业客户快速触达手机用户所优选使用的通信能力。调用API或用群发助手,即可发送验证码、通知类和营销类短信;国内验证短信秒级触达,到达率最高可达99%;国际/港澳台短信覆盖200多个国家和地区,安全稳定,广受出海企业选用。</div
          >
        </div>
        <div class="imgBig1"><img class="imgBig" src="../../../public/image/promotionActivity/img2.png" alt="" /></div>
        <div class="base5G">
          基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G专基于5G。
        </div>
        <div class="base5G2">支持多种推广内容的短信发放,例如业务推广、新产品宣讲、会员关怀等内容的短信,为提升企业产品增加曝光率提供帮助。</div>

        <div class="mostActivityTitle"> 更多活动 </div>

        <!-- 6个框 -->
        <div style="margin-top: 34px">
          <div class="piece3" style="display: flex">
            <!-- 一个框 -->
            <div class="piece1" v-for="(i, index) in contentData" :key="'i-' + index">
              <!-- 文字内容 -->
              <div class="contextTop">
                <div class="alreadEnd">
                  <div class="alreadEndFont" :class="i.statusName">{{ i.status }}</div>
                </div>
                <div class="pieceTitile">{{ i.title }}</div>
                <div class="pieceContent">{{ i.introduce }}</div>
                <div class="limitYouHui">
                  <div class="limitYouHuiFont" v-for="(i2, index) in i.preference" :key="index">
                    {{ i2.prefer }}
                  </div>
                </div>
              </div>
              <div class="pieceLine"></div>

              <!-- 查看详情 -->
              <div class="checkXianqing">查看详情</div>
            </div>
          </div>
        </div>
        <div style="margin-top: 40px; padding-bottom: 80px">
          <div class="gengDouHuoDong">
            <div class="gengDouHuoDongFont">查看更多活动</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
     contentData: [
          {
            status: '已结束',
            statusName: '',
            title: '5G建网企业方案',
            introduce: '5G建网企业方案与企业信息系统终端界面集成,基于 web客户端的界面',
            preference: [{ prefer: '限时特惠' }],
          },
          {
            status: '未开始',
            statusName: 'unStart',
            title: '5G建网企业方案',
            introduce: '5G建网企业方案与企业信息系统终端界面集成,基于 web客户端的界面',
            preference: [{ prefer: '限时特惠' }, { prefer: '爆款选购' }],
          },
          {
            status: '进行中',
            statusName: 'ing',
            title: '5G建网企业方案',
            introduce: '5G建网企业方案与企业信息系统终端界面集成,基于 web客户端的界面',
            preference: [{ prefer: '限时特惠' }],
          },
          {
            status: '已结束',
            statusName: '',
            title: '5G建网企业方案',
            introduce: '5G建网企业方案与企业信息系统终端界面集成,基于 web客户端的界面',
            preference: [{ prefer: '限时特惠' }],
          },
          {
            status: '未开始',
            statusName: 'unStart',
            title: '5G建网企业方案',
            introduce: '5G建网企业方案与企业信息系统终端界面集成,基于 web客户端的界面',
            preference: [{ prefer: '限时特惠' }, { prefer: '爆款选购' }],
          },
          {
            status: '进行中',
            statusName: 'ing',
            title: '5G建网企业方案',
            introduce: '5G建网企业方案与企业信息系统终端界面集成,基于 web客户端的界面',
            preference: [{ prefer: '限时特惠' }],
          },
        ],
      }
    }
  }
</script>

<style>
* {
    margin: 0px 0px;
  padding: 0px 0px;
}
.out {
  display: flex;
  justify-content: center;
  /* 左右居中 */
}
.img1 {
  /* src: url(../../../public/image/promotionActivity/img1.png); */
  width: 576px;
  height: 324px;
  opacity: 1;
}
.top {
  margin-top: 56px;
  display: flex;
}
.mostActivity {
  width: 130px;
  height: 40px;
  opacity: 1;
  font-size: 24px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: left;
  color: #202020;
  line-height: 40px;
}
.topText {
  margin-left: 40px;
}
.MessageService {
  margin-top: 40px;
  width: 584px;
  height: 66px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: left;
  color: #333333;
  line-height: 22px;
}
.icon1 {
  margin-right: 8px;
  width: 24px;
  height: 24px;
  opacity: 1;
  margin-top: 32px;
}
.day {
  height: 22px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: left;
  color: #666666;
  line-height: 22px;
  margin-top: 33px;
}
.iconContext {
  display: flex;
}
.button {
  width: 104px;
  height: 36px;
  opacity: 1;
  background: #2d65fe;
  margin-top: 87px;
  text-align: center;
}
.buttonFont {
  width: 104px;
  height: 36px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: center;
  color: #ffffff;
  line-height: 36px;
  background: #2d65fe;

}
.xianqing {
  width: 521px;
  height: 40px;
  opacity: 1;
  font-size: 24px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: left;
  color: #202020;
  line-height: 40px;
  margin-top: 40px;
}
.line {
  margin-top: 20px;
}
.lineBlue {
  width: 96px;
  height: 4px;
  opacity: 1;
  background: #2d65fe;
}
.lineLong {
  /* margin-top: 4px; */
  width: 1200px;
  height: 1px;
  opacity: 1;
  border: 1px solid #d9d9d9;
}
.messageServiceContent {
  margin-top: 56px;
  width: 1200px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: left;
  color: #333333;
  line-height: 22px;
}
.imgBig {
  width: 1200px;
  height: 675px;
  opacity: 1;
  margin-top: 40px;
}
.base5G {
  margin-top: 40px;
  width: 1200px;
  height: 44px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: left;
  color: #333333;
  line-height: 22px;
}
.base5G2 {
  margin-top: 24px;
  width: 1200px;
  height: 22px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: left;
  color: #333333;
  line-height: 22px;
}
.mostActivityTitle {
  width: 112px;
  height: 40px;
  opacity: 1;
  font-size: 28px;
  font-family: PingFangSC, PingFangSC-Medium;
  font-weight: 500;
  text-align: center;
  color: #333333;
  line-height: 40px;
  padding-top: 136px;
  display: flex;
  justify-content: center;
  margin: 0px auto;
  /* 左右居中 */
}
.piece1 {
  width: 380px;
  height: 229px;
  opacity: 1;
  background: #ffffff;
  border: 1px solid #eeeeee;
  border-radius: 3px;
  box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.05);
  margin-top: 30px;
}
.piece2 {
  margin-left: 30px;
  width: 380px;
  height: 229px;
  opacity: 1;
  background: #ffffff;
  border: 1px solid #eeeeee;
  border-radius: 3px;
  box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.05);
}
.piece3{
   width: 1200px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}
.threePiece {
  margin-top: 30px;
  display: flex;
}

.contextTop {
  width: 356px;
  height: 181px;
  opacity: 1;
  padding-left: 24px;
}

.alreadEnd {
  width: 64px;
  height: 24px;
  opacity: 1;
  background: #a1a1a1;
  border-radius: 0px;
  line-height: 24px;
  /* display: flex;
  justify-content: flex-end; */
  float: right;
}
.alreadEndFont {
  width: 36px;
  height: 16px;
  opacity: 1;
  font-size: 12px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: center;
  color: #ffffff;
  line-height: 24px;
  margin: 0px auto;
  line-height: 24px;
}
.pieceTitile {
  clear: both;
  width: 332px;
  height: 22px;
  opacity: 1;
  font-size: 16px;
  font-family: PingFangSC, PingFangSC-Semibold;
  font-weight: 600;
  text-align: left;
  color: #333333;
  line-height: 22px;
}
.pieceContent {
  padding-top: 14px;
  width: 332px;
  height: 44px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: left;
  color: #666666;
  line-height: 22px;
  padding-bottom: 32px;
}
.limitYouHui {
  display: flex;
  justify-content: left;
}
.limitYouHui1 {
  width: 64px;
  height: 21px;
  opacity: 1;
  background: #ffffff;
  border-radius: 3px;
  margin-left: 30px;
  margin-top: 8px;
}
.limitYouHuiFont {
  width: 48px;
  height: 17px;
  line-height: 17px !important;
  padding:2px 8px ;
  text-align: center;
  opacity: 1;
  font-size: 12px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  color: #2d65fe;
  line-height: 21px;
margin-left: 8px;
    border: 1px solid #2d65fe;
  border-radius: 3px;

}
.pieceLine {
  width: 380px;
  height: 1px;
  opacity: 1;
  border: 1px solid #eaeaea;
}
.checkXianqing {
  padding-top: 14px;
  width: 100px;
  height: 20px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Semibold;
  font-weight: 600;
  text-align: center;
  color: #2d65fe;
  line-height: 20px;
  margin: 0px auto;
  padding-bottom: 14px;
}
.checkXianqing:hover{
background-color: #2d65fe;
color: white;
width: 382px;
}
.ing {
  width: 64px;
  height: 24px;
  opacity: 1;
  background: #fe7532;
  border-radius: 0px;
  line-height: 24px;
  float: right;
}
.ingFont {
  width: 36px;
  height: 16px;
  opacity: 1;
  font-size: 12px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: center;
  color: #ffffff;
  line-height: 24px;
  margin: 0px auto;
  line-height: 24px;
}
.unStart {
  width: 64px;
  height: 24px;
  opacity: 1;
  background: #2d65fe;
  border-radius: 0px;
  line-height: 24px;
  float: right;
}

.unStartFont {
  width: 36px;
  height: 16px;
  opacity: 1;
  font-size: 12px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: center;
  color: #ffffff;
  line-height: 24px;
  margin: 0px auto;
  line-height: 24px;
}
.baoKuan {
  width: 64px;
  height: 21px;
  opacity: 1;
  background: #ffffff;
  border: 1px solid #2d65fe;
  border-radius: 3px;
  margin-left: 8px;
}
.baoKuanFont {
  width: 48px;
  height: 17px;
  opacity: 1;
  font-size: 12px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  color: #2d65fe;
  line-height: 21px;
  margin: 0px auto;
}

.gengDouHuoDong {
  width: 132px;
  height: 36px;
  opacity: 1;
  border: 1px solid #2d65fe;
  margin: 0px auto;
}
.gengDouHuoDongFont {
  width: 84px;
  height: 22px;
  opacity: 1;
  font-size: 14px;
  font-family: PingFangSC, PingFangSC-Regular;
  font-weight: 400;
  text-align: center;
  color: #2d65fe;
  line-height: 36px;
  margin: 0px auto;
}
@media screen and (max-width: 750px) {
  .img11 {
    margin: 0px auto;
    width: 100vw;
    height: 211px;
  }
  .img1 {
    width: 100vw;
    height: 211px;
    /* margin-left: 300px; */
  }
  .top {
    display: block;
  }
  .topText {
    padding-top: 25px;
    margin: 0px auto;
    /* text-align: center; */
    width: 100vw;
  }
  .MessageService {
    margin: 0px auto;
    width: 90vw;
  }

  .MessageService1 {
    padding: 16px;
  }
  .mostActivity {
    margin: 0px auto;
    /* width: 100vw; */
    padding-left: 16px;
    /* padding-top: 25px; */
    white-space: nowrap;
  }
  .iconContext {
    width: 100vw;
    padding-left: 16px;
    margin-bottom: 38px;
  }
  .button {
    width: 90vw;
    height: 50px;
     margin: 0px auto;
  }
  .buttonFont {
    /* text-align: center; */
    font-size: 20px;
    margin: 0px auto;
    white-space: nowrap;
    padding-top: 6px;
  }
  .limitYouHui1 {
    margin-right: 180px;
    margin-top: 8px;
  }
  .xianqing{
    width: 90vw;
    margin: 0px auto;
    padding-top: 50px;
    color: #2d65fe;

  }
  .line{
     width: 90vw;
    margin: 0px auto;
  }
  .messageServiceContent{
      width: 90vw;
    margin: 0px auto;
    padding-top: 25px;
    padding-bottom: 25px;
  }
  .imgBig{
     width: 90vw;
    margin: 0px auto;
    height: 211px;
  }
    .imgBig1{
     width: 90vw;
    margin: 0px auto;
  }
  .base5G{
     width: 90vw;
    margin: 0px auto;
    padding-top: 25px;
  }
  .base5G2{
     width: 90vw;
    margin: 0px auto;
  padding-top: 90px;
  }
  .piece3{
  display: block;  
   width: 90vw;
    margin: 0px auto;
  
}

}
</style>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值