当前位置: 首页 > news >正文

uniapp 微信小程序 上下滚动的公告通知(只取前3条)

效果图:
在这里插入图片描述

<template><view class="notice" @click="policyInformation"><view class="notice-icon"><image mode="aspectFit" class="img" src="@/static/img/megaphone.png"></image></view><view class="notice-content"><swiper circular :autoplay="true" :vertical="true"><swiper-item class="flex justify-content-between" v-for="(item, index) in noticeBarList":key="index" @click="toNotice(item)"><text class="text text-ellipsis flex-grow">{{ item.mtitle }}</text></swiper-item></swiper></view><view class="notice-arrow"><image mode="aspectFit" class="img" src="@/static/img/supervisoryEnd/arrow.png"></image></view></view>
</template>
data() {return {noticeBarList: [],	}
}
onLoad: function(options) {this.getNotice()
},
methods: {//查询通知公告getNotice(){uni.showLoading();var params = {url: "/transporterList",method: "GET",data: {readStatus:-1},callBack: res => {uni.hideLoading()if(res.rows.length > 3){//最多只显示前三个通知this.noticeBarList = res.rows.slice(0,3);}else{								this.noticeBarList = res.rows;}}};http.request(params);},//进入公告通知详情页toNotice(item){uni.navigateTo({url:"/pages/notice-detail/notice-detail?messageId="+item.messageId})},
}
<style lang="scss" scoped>
.notice {display: flex;display: -webkit-flex;align-items: center;box-shadow: 0rpx 2rpx 10rpx 0rpx rgba(0, 0, 0, 0.05);background: rgba(255, 255, 255, 0.8);margin-top: 20rpx;border-radius: 10rpx;.notice-icon {.img {display: block;width: 30rpx;height: 30rpx;margin-left: 15rpx;}}.notice-content {flex-grow: 1;swiper {height: 56rpx;padding: 0 17rpx;swiper-item {display: flex;display: -webkit-flex;align-items: center;justify-content: space-between;.text {height: 56rpx;font-size: 26rpx;color: #666666;line-height: 56rpx;flex-grow: 1;}}}}.notice-arrow {.img {display: block;width: 32rpx;height: 32rpx;}}
}
</style]>
http://www.lryc.cn/news/113295.html

相关文章:

  • OSPF在MGRE上的实验
  • 什么样的跨网文件安全交换系统 可实现安全便捷的文件摆渡?
  • C语言memset函数的作用
  • 暑假刷题第23天--8/7
  • Double DQN缓解动作价值的高估问题
  • 【C#学习笔记】内存管理
  • 面试之快速学习c++11- 列表初始化和 lambda匿名函数的定义
  • CI/CD—Docker初入门学习
  • 多线程的创建,复习匿名内部类,Thread的一些方法,以及lambda的变量捕捉,join用法
  • 瑞吉外卖系统05
  • D455+VINS-Fusion+surfelmapping 稠密建图(三)
  • rv1109/1126 rknn 模型部署过程
  • Android平台一对一音视频通话方案对比:WebRTC VS RTMP VS RTSP
  • --binlog-row-event-max-size
  • Jmeter命令行运行实例讲解
  • pl/sql函数如何返回多行数据?在线等......
  • Ubuntu Find命令详解
  • ADS Momentum学习笔记
  • 解决Vue3 使用Element-Plus导航刷新active高亮消失
  • K8S系列文章之 一键部署K8S环境
  • Spring Boot、Spring Cloud、Spring Alibaba 版本对照关系及稳定兼容版本
  • 虫情监测仪介绍—技术原理、功能优势是什么?
  • HTML5 Canvas和Svg:哪个简单且好用?
  • ChatGPT在社交媒体聊天和评论分析中的应用如何?
  • DoIP学习笔记系列:(四)用CAPL脚本读取DID的关键点
  • chrome插件开发实例06-定制自己的Chrome DevTools调试工具
  • 安卓读取,添加,更新,删除联系人,读取短信
  • Practices6|69. x 的平方根、(哈希表)205. 同构字符串、(哈希表)1002. 查找共用字符
  • Qt扫盲-Model/View入门
  • 关于win11 debian wsl 子系统安装启动docker一直starting,无法启动