码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 新闻轮播图


    一、效果图

    二、vue中html部分

    1. <div class="swiper-container" ref="swiperDom">
    2. <div class="swiper-wrapper">
    3. <div class="swiper-slide" v-for="(item,index) in newsImageList" :key="index">
    4. <img class="image" :src="item.imageUrl">
    5. div>
    6. div>
    7. <div class="swiper-pagination">div>
    8. <div class="title pl-12">{{ swiperTitle }}div>
    9. div>

    三、vue中相关js代码

    1. let state = reactive({
    2. timer:null,
    3. newsImageList:[],
    4. async getImageList(){
    5. let data={
    6. page:PAGEITEM.page,
    7. size:PAGEITEM.size,
    8. }
    9. let res = await getImageList(data)
    10. if(res.code===SUCCESS_CODE){
    11. state.newsImageList=res.data.records
    12. }else{
    13. state.newsImageList=[]
    14. }
    15. },
    16. swiper: {},
    17. swiperTitle:'',
    18. initSwiper() {
    19. //@ts-ignore
    20. state.swiper = new Swiper(swiperDom.value, {
    21. // Swiper的配置选项
    22. pagination: {//页脚(标题部分)
    23. el: '.swiper-pagination',
    24. },
    25. on:{//这里是为了实现手写title获取
    26. transitionEnd : function(e){
    27. let index=(e.activeIndex===(state.newsImageList.length+1))?1:e.activeIndex
    28. state.swiperTitle=state.newsImageList[index-1].title
    29. },
    30. },
    31. //自动轮播
    32. autoplay: {
    33. delay: 2500,//时间 毫秒
    34. disableOnInteraction: false,//用户操作之后是否停止自动轮播默认true
    35. },
    36. loop:true,//循环 最后面一个往后面滑动会滑到第一个
    37. });
    38. },
    39. });
    40. onMounted(async () => {
    41. await state.getImageList()
    42. state.timer = setTimeout(() => {
    43. state.initSwiper();
    44. }, 100)
    45. });
    46. onUnMounted(()=>{
    47. state.timer=null
    48. })

    四、less代码

    1. .swiper-container {
    2. width: 100%;
    3. height: 100%;
    4. position:relative;
    5. :deep(.swiper-slide) {
    6. width: 100%;
    7. height: 100%;
    8. img {
    9. width: 100%;
    10. height: 100%;
    11. }
    12. }
    13. .title{
    14. height: 50px;
    15. line-height: 50px;
    16. position: relative;
    17. top:-50px;
    18. color:#fff;
    19. z-index: 10;
    20. width: 70%;
    21. .ellipsis;
    22. }
    23. :deep(.swiper-pagination){
    24. background: rgba(00,00,00,.7);
    25. height: 50px;
    26. bottom: 0;
    27. display: flex;
    28. justify-content: flex-end;
    29. align-items: center;
    30. padding-right: 24px;
    31. .swiper-pagination-bullet {
    32. background: rgba(255,255,255,.9);
    33. }
    34. .swiper-pagination-bullet-active{
    35. background: #fff;
    36. }
    37. }
    38. }

  • 相关阅读:
    Factory IO v2.5.2 Crack by Xacker
    python学习:break用法详解
    在C代码中找到栈顶的位置并访问栈空间
    怎么把手机ip地址变成了外省
    外贸开发信主题怎么写?营销邮件标题推荐?
    【黑马-SpringCloud技术栈】【01】完整的微服务技术栈_微服务技术对比
    BFS解决FloodFill算法:(Leetcode:200. 岛屿数量)
    Rust学习记录(linux)——安装、创建、编译、输入输出
    【Android笔记30】Android中数据存储之SQLite数据库
    python项目上线
  • 原文地址:https://blog.csdn.net/weixin_59017683/article/details/132830142
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号