写在前面:
这次我主要想总结一下微信小程序实现上下滚动消息提醒,主要是利用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>

本文介绍了如何在微信小程序中使用swiper组件实现上下滚动的公告消息提醒。关键在于设置swiper组件的vertical属性为true,数据通过setData函数传递到视图层。示例包括wxml、wxss和Js代码段。
订阅专栏 解锁全文
6911

被折叠的 条评论
为什么被折叠?



