写在前面:
这次我主要想总结一下微信小程序实现上下滚动消息提醒,主要是利用swiper组件来实现,swiper组件在小程序中是滑块视图容器。
我们通过vertical属性(默认为false,实现默认左右滚动)设置为true来实现上下滚动。
(需要注意的是:只要你的swiper存在vertical属性,无论你给值为true或者false或者不设参数值,都将实现上下滚动)
wxml
1 <swiper class="swiper_container" vertical="true" autoplay="true" circular="true" interval="2000"> 2 <block wx:for="{ {msgList}}"> 3 <navigator url="/pages/index/index?title={ {item.url}}" open-type="navigate"> 4 <swiper-item> 5 <view class="swiper_item">{ {item.title}}</view> 6 </swiper-item> 7 </navigator>