Angular搭配Swiper-分页不工作
创始人
2024-10-24 00:31:32
0
  1. 确保你在 HTML 文件中正确地使用了 Swiper 分页,例如:

  Slide 1
  Slide 2
  Slide 3

  
  1. 在组件文件中引入 ngx-swiper-wrapper 组件:
import { SwiperOptions } from 'swiper';

// ...

export class MyComponent {
  public config: SwiperOptions = {
    // Swiper 分页选项
    pagination: { el: '.swiper-pagination', clickable: true }
  };
}
  1. 在 HTML 文件中使用 ngx-swiper-wrapper 组件:

  {{ item }}

  
  1. 在组件文件中初始化 Swiper:
import { ViewChild, AfterViewInit } from '@angular/core';
import { SwiperComponent } from 'ngx-swiper-wrapper';

// ...

export class MyComponent implements AfterViewInit {
  // 获取 ViewChild 实例
  @ViewChild(SwiperComponent) public componentRef?: SwiperComponent;

  // ...

  public ngAfterViewInit(): void {
    // 等待渲染完成后初始化 Swiper
    setTimeout(() => {
      if (this.componentRef) {
        this.componentRef.swiper().update();
      }
    });
  }
}

相关内容

热门资讯

揭露透视!wepoker有什么... 揭露透视!wepoker有什么规律,微乐脚本,诀窍教程(有挂技巧)-哔哩哔哩一、wepoker有什么...
关于透视!pokermaste... 关于透视!pokermaster辅助器,微乐陕西小程序破解器下载,经验教程(有挂秘籍)-哔哩哔哩1、...
揭露透视!hhpkoer辅助器... 揭露透视!hhpkoer辅助器,微信小程序微乐游戏辅助,大纲教程(有挂方法)-哔哩哔哩1、超多福利:...
揭幕透视!we poker辅助... 揭幕透视!we poker辅助器,微信微乐陕西挖坑小程序破解器,阶段教程(有挂助手)-哔哩哔哩1、用...
揭露透视!wepoker提高好... 揭露透视!wepoker提高好牌率,如何下载微乐自建房黑科技入口,经验教程(真是有挂)-哔哩哔哩1、...
了解透视!wepoker透视有... 您好,wepoker透视有用吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054...
开挂透视!wepoker手机插... 开挂透视!wepoker手机插件,微乐自建房道具有用吗,法门教程(有挂透明挂)-哔哩哔哩1、用户打开...
总结透视!约局吧德州真的有透视... 总结透视!约局吧德州真的有透视挂吗,微乐自建房安装挂,资料教程(有挂方法)-哔哩哔哩1、打开软件启动...
科普透视!xpoker怎么作弊... 科普透视!xpoker怎么作弊,微乐游戏小程序脚本,方针教程(有挂透明挂)-哔哩哔哩1、科普透视!x...
解密透视!德普软件,微乐小程序... 解密透视!德普软件,微乐小程序辅助开发,办法教程(有挂分享)-哔哩哔哩1、在德普软件插件功能辅助器技...