此次我主要想总结一下微信小程序实现上下滚动消息提醒,主要是利用swiper组件来实现,swiper组件在小程序中是滑块视图容器。小程序
咱们经过vertical属性(默认为false,实现默认左右滚动)设置为true来实现上下滚动。微信小程序
(须要注意的是:只要你的swiper存在vertical属性,不管你给值为true或者false或者不设参数值,都将实现上下滚动)微信
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> 8 </block> 9 </swiper>
1 .swiper_container { 2 height: 55rpx; 3 width: 80vw; 4 } 5 6 .swiper_item { 7 font-size: 25rpx; 8 overflow: hidden; 9 text-overflow: ellipsis; 10 white-space: nowrap; 11 letter-spacing: 2px; 12 }
1 var app = getApp() 2 Page({ 3 data: { 4 }, 5 onLoad(e) { 6 console.log(e.title) 7 this.setData({ 8 msgList: [ 9 { url: "url", title: "公告:多地首套房贷利率上浮 热点城市渐迎零折扣时代" }, 10 { url: "url", title: "公告:悦如公寓三周年生日趴邀你免费吃喝欢唱" }, 11 { url: "url", title: "公告:你想和一群有志青年一块儿过生日嘛?" }] 12 }); 13 } 14 })
数据放在了setData函数中,setData函数的主要做用是将数据从逻辑层发送到视图层,可是须要避免单次设置大量的数据。app
大一暑假已通过去一半,但愿我此次广东的两星期之行,能够帮助我下一段的学习在对知识强烈渴望中度过,这样在本身求之不得的地方面前,不会感受到本身的眇小和知识的匮乏而望而却步,不敢走近。xss
其实行走匆匆的人,不必定是无意观赏两岸的风景,或许在他的心中,有些不可替代的风景,而他匆匆的脚步就是为了他心中的''景色''。函数