【微信小程序】实现公告栏滚动效果

时间:2021-02-26 12:53:34   收藏:0   阅读:0

技术图片

data:

msgList: [
  { title: ‘你有一笔奖励待发放‘ },
  { title: ‘1.8元津贴到账,快点去打车吧‘ },
  { title: ‘单单八折赢iPhone,一路迎春“发”‘ }
],

wxml:

<view class="notice">
  <view class="left">
    <image src="../../images/notice.png" mode="aspectFit"></image>
    <swiper vertical="true" autoplay="true" circular="true" interval="3000" duration=‘800‘>
      <block wx:for=‘{{msgList}}‘ wx:key=‘index‘>
        <swiper-item>
          <view class="swiper-item">{{item.title}}</view>
        </swiper-item>
      </block>
    </swiper>
  </view>
  <view class="right">
    <text>新消息</text>
    <text>10</text>
    <image class="" src="../../images/5.png" mode="aspectFit"></image>
  </view>
</view>

css:

.notice{
    background: #fff;
    padding: 30rpx;
    border-radius: 30rpx;
    .flex-center();
    justify-content: space-between;
    .left{
        width: 70%;
        display: flex;
        image{
            width: 40rpx;
            height: 40rpx;
            vertical-align: middle;
            margin-right: 12rpx;
        }
        swiper{
            width: 90%;
            height: 50rpx;
            swiper-item{
                width: 100%;
                height: 100%;
                view{
                    width: 100%;
                    color: #666;
                    font-size: 28rpx; 
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                }
            }
        }
    }
    .right{
        .flex-center();
        text{
            &:nth-child(1){
                font-size: 22rpx;
                color: #999;
            }
            &:nth-child(2){
                display: inline-block;
                font-size: 18rpx;
                width: 32rpx;
                height: 32rpx;
                background: #ed1c93;
                border-radius: 32rpx;
                color: #fff;
                text-align: center;
                line-height: 32rpx;
                margin: 0 10rpx;
            }
        }
        image{
            width: 30rpx;
            height: 30rpx;
        }
    }
}
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!