编程语言
首页 > 编程语言> > 【微信小程序】实现公告栏滚动效果

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

作者:互联网

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;
        }
    }
}

标签:滚动,公告栏,32rpx,title,color,微信,height,width,30rpx
来源: https://www.cnblogs.com/cdnotes/p/14445997.html