微信小程序公告滚动通知
微信小程序实现上下滚动消息提醒,主要是利用swiper组件来实现,swiper组件在小程序中是滑块视图容器。
通过vertical属性(默认为false,实现默认左右滚动)设置为true来实现上下滚动。
只要你的swiper存在vertical属性,无论你给值为true或者false或者不设参数值,都将实现上下滚动
-
效果图
左右滚动 -
wxml code
<!-- 公告 -->
<view class='adsec'>
<icon class='iconfont icongonggao c_main fs_36'></icon>
<text class='c_main fs_26'>公告:</text>
<swiper class="swiper_container" autoplay="true" circular="true" interval="2000">
<block wx:for="{{msgList}}">
<navigator url="/pages/index/index?title={{item.url}}" open-type="navigate">
<swiper-item>
<view class="swiper_item">{{item.title}}</view>
</swiper-item>
</navigator>
</block>
</swiper>
</view>
<!-- 公告 end -->
- wxs code
.adsec{
width: 90%;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
margin: 10rpx auto;
background:rgba(254,242,242,1);
border-radius:6px;
padding: 7rpx 10rpx;
height: 50rpx;
}
.adsec icon{
display: flex;
margin-right: 10rpx;
}
.swiper_container {
height: 55rpx;
width: 80%;
line-height: 55rpx;
padding-left: 10rpx;
}
.swiper_item {
font-size: 25rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
letter-spacing: 2px;
}
- js
msgList: [
{ url: "url", title: "恭喜xxx完成任务退回200进入领奖区" },
{ url: "url", title: "恭喜xxx获得XXX奖励" },
{ url: "url", title: "恭喜xxx完成任务退回300进入领奖区" }]
来源:https://www.jianshu.com/p/71502ae00d5c
作者:子钦加油
出处:https://www.cnblogs.com/zmdComeOn/
个性签名:努力生活,努力走路
阿里云拼团:https://www.aliyun.com/1111/home?userCode=f4ee1llo1核2G1M,86一年,229三年;2核4G5M,799三年;2核8G5M,1399三年
腾讯云三月采购计划特价:https://cloud.tencent.com/act/cps/redirect?redirect=1073&cps_key=15d0b1673287c43fe946626d9f4e2eee&from=console1核2G1M,88一年;1核2G1M,268三年;2核4G5M,998一年;4核8G5M,2888元三年
出处:https://www.cnblogs.com/zmdComeOn/
个性签名:努力生活,努力走路
阿里云拼团:https://www.aliyun.com/1111/home?userCode=f4ee1llo1核2G1M,86一年,229三年;2核4G5M,799三年;2核8G5M,1399三年
腾讯云三月采购计划特价:https://cloud.tencent.com/act/cps/redirect?redirect=1073&cps_key=15d0b1673287c43fe946626d9f4e2eee&from=console1核2G1M,88一年;1核2G1M,268三年;2核4G5M,998一年;4核8G5M,2888元三年

浙公网安备 33010602011771号