uniapp 纵向滚动公告

以纵向滚动公告为例,默认显示两条数据
template

<template>
    <view class="notice_bg">
        <image class="icon" :src="noticeImg"></image>
        <view class="line"></view>
        <swiper autoplay="true" display-multiple-items="2" vertical="true" circular interval="2000" class="bar-swiper">
            <swiper-item v-for="(item, index) in list" :key="index" class="swiper-item">
                <view class="circle"></view>
                <view class="item_box" @tap="click(item.id)">
                    {{ item.articleTitle }}
                </view>
            </swiper-item>
        </swiper>
    </view>
</template>

script

<script>
    export default{
        data(){
            return {
                  noticeImg:'',//左侧图片
                  list:[
                          {
                           articleTitle: "文章标题001",
                            id: "36"
                          },
                          {
                           articleTitle: "文章标题002",
                            id: "37"
                          },
                         {
                           articleTitle: "文章标题003",
                            id: "38"
                          },
                          {
                           articleTitle: "文章标题004",
                            id: "39"
                          },
                        ]
            }
        },
        methods:{
            // 点击通告栏
            click(id) {
                console.log(id,'======>id')
            }
        }
    }
</script>

css

<style scoped lang="scss">
    .notice_bg{
        margin: 32rpx;
        background-color: #FFFFFF;
        border-radius: 8rpx;
        padding: 16rpx 20rpx;
        display: flex;
        align-items: center;
        .icon{
            width: 74rpx;
            height: 72rpx;
        }
        .line{
            margin: 0 16rpx 0 20rpx;
            background-color: #F4F4F4;
            width: 2rpx;
            height: 68rpx;
        }
        .bar-swiper{
            font-size: 24rpx;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(34, 34, 34, 0.5);
            height: 80rpx;
            display: flex;
            align-items: center;
            flex: 1;
            margin-left: 12rpx;
        }
        .swiper-item {
            display: flex;
            align-items: center;
            overflow: hidden;
        }
        .circle{
            min-width: 10rpx;
            width: 10rpx;
            height: 10rpx;
            border-radius: 50%;
            background-color: rgba(34, 34, 34, 0.5);
            margin-right: 10rpx;
        }
        .item_box{
            word-break: break-all;  /* break-all(允许在单词内换行。) */
            text-overflow: ellipsis;  /* 超出部分省略号 */
            display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
            -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
            -webkit-line-clamp: 1; /** 显示的行数 **/
        }
    }
</style>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • vue的核心是什么? Vue 的核心设计理念可以概括为以下 5 个关键要素,这些要素共同构成了 Vue 的独特优势...
    Aniugel阅读 9,693评论 3 21
  • 第一章 1、使用浏览器去访问的程序,叫网页 2、web代码存放在服务器 代码分为两种:① 运行在浏览器端:前端代...
    fastwe阅读 3,442评论 0 2
  • 首先介绍一下uiapp框架:uni-app 是一个使用 Vue.js[https://vuejs.org/] 开发...
    Iniox阅读 1,682评论 0 6
  • 前言 html5Canvas的知识点,是开发的必备技能,在实际工作中也常常会涉及到。 最近熬夜总结html5Can...
    Afine_4d71阅读 696评论 0 0
  • 狂神说Vue笔记 想要成为真正的“互联网Java全栈工程师”还有很长的一段路要走,其中前端是绕不开的一门必修课。本...
    华夏天骄阅读 840评论 0 0