微信小程序如何实现左右滚动公告栏效果?
- 内容介绍
- 文章标签
- 相关推荐
本文共计497个文字,预计阅读时间需要2分钟。
这篇文章主要介绍了微信小程序左右滑动公告栏的效果实现代码实例。文中通过示例代码详细介绍了实现过程,对初学者或工作者具有一定的参考学习价值。需要的伙伴可参考以下代码示例:
vi// 示例代码 {{item.title}}
以上代码中,`swiper` 组件实现了左右滑动的效果。`autoplay` 属性控制自动播放,`interval` 设置自动播放时间间隔,`duration` 设置滑动动画时长,`indicator-dots` 显示指示点,`circular` 设置是否循环播放。
`swiperList` 是一个数组,包含每个公告的,`wx:for` 循环遍历数组,将每个公告的显示在 `swiper-item` 中。
这篇文章主要介绍了微信小程序左右滚动公告栏效果代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
代码如下
<view class='notice-wrap' hidden='{{hideNotice}}'> <view class='tongzhitext'> <text class="tongzhi-text">{{notice}}</text> </view> <view bindtap='switchNotice' class="closeView">x</view> </view>
data: { //初始化数据 hideNotice: false, notice: '', } // 点击关闭公告 switchNotice: function() { this.setData({ hideNotice: true }) },
@keyframes remindMessage { 0% { -webkit-transform: translateX(90%); } 100% { -webkit-transform: translateX(-180%); } } .tongzhitext { margin-right:80rpx; margin-left: 10rpx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .tongzhi-text { font-size: 28rpx; animation: remindMessage 14s linear infinite; width: 100%; color: #d09868; display: block; } .notice-wrap { background: #ffebda; width: 100%; height: 60rpx; line-height: 60rpx; color: #d09868; font-size: 28rpx; } .closeView { width: 45rpx; height: 45rpx; line-height: 45rpx; position: absolute; right: 20rpx; top: 5rpx; text-align: center; font-size: 35rpx; }
效果展示
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。
本文共计497个文字,预计阅读时间需要2分钟。
这篇文章主要介绍了微信小程序左右滑动公告栏的效果实现代码实例。文中通过示例代码详细介绍了实现过程,对初学者或工作者具有一定的参考学习价值。需要的伙伴可参考以下代码示例:
vi// 示例代码 {{item.title}}
以上代码中,`swiper` 组件实现了左右滑动的效果。`autoplay` 属性控制自动播放,`interval` 设置自动播放时间间隔,`duration` 设置滑动动画时长,`indicator-dots` 显示指示点,`circular` 设置是否循环播放。
`swiperList` 是一个数组,包含每个公告的,`wx:for` 循环遍历数组,将每个公告的显示在 `swiper-item` 中。
这篇文章主要介绍了微信小程序左右滚动公告栏效果代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
代码如下
<view class='notice-wrap' hidden='{{hideNotice}}'> <view class='tongzhitext'> <text class="tongzhi-text">{{notice}}</text> </view> <view bindtap='switchNotice' class="closeView">x</view> </view>
data: { //初始化数据 hideNotice: false, notice: '', } // 点击关闭公告 switchNotice: function() { this.setData({ hideNotice: true }) },
@keyframes remindMessage { 0% { -webkit-transform: translateX(90%); } 100% { -webkit-transform: translateX(-180%); } } .tongzhitext { margin-right:80rpx; margin-left: 10rpx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } .tongzhi-text { font-size: 28rpx; animation: remindMessage 14s linear infinite; width: 100%; color: #d09868; display: block; } .notice-wrap { background: #ffebda; width: 100%; height: 60rpx; line-height: 60rpx; color: #d09868; font-size: 28rpx; } .closeView { width: 45rpx; height: 45rpx; line-height: 45rpx; position: absolute; right: 20rpx; top: 5rpx; text-align: center; font-size: 35rpx; }
效果展示
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。

