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();
      }
    });
  }
}

相关内容

热门资讯

透视辅助!hhpoker德州挂... 透视辅助!hhpoker德州挂真的有吗,hhpoker软件靠谱吗,AI教程(有挂脚本);1、每一步都...
透视了解!wpk可以作弊吗,w... 透视了解!wpk可以作弊吗,wpk辅助哪里买,曝光教程(有挂方法)1、点击下载安装,wpk可以作弊吗...
透视安卓版!hhpoker有没... 透视安卓版!hhpoker有没有辅助,hhpoker有辅助吗,详细教程(有挂介绍);该软件可以轻松地...
透视安卓版!wpk辅助插件,w... 透视安卓版!wpk辅助插件,wpk透视插件,透视教程(有挂规律)所有人都在同一条线上,像星星一样排成...
透视ai!hhpoker透视工... 透视ai!hhpoker透视工具,hhpoker一直输有挂吗,细节方法(有挂规律)1、下载好hhpo...
透视好友房!wpk作弊最怕三个... 透视好友房!wpk作弊最怕三个东西,wpk透视插件,教你攻略(有挂脚本)1、首先打开wpk作弊最怕三...
透视好友!hhpoker辅助,... 透视好友!hhpoker辅助,hhpoker到底可以作弊吗,新2025版(有挂规律)1、下载好hhp...
透视透视!wpk俱乐部是做什么... 透视透视!wpk俱乐部是做什么的,wpk有那种辅助吗,2025新版教程(有挂规律)透视透视!wpk俱...
透视科技!hhpoker是真的... 透视科技!hhpoker是真的还是假的,hhpoker辅助器,技巧教程(有挂黑科技)1、hhpoke...
透视神器!wpk辅助,wpk是... 透视神器!wpk辅助,wpk是真的还是假的,详细教程(有挂解密);1、wpk是真的还是假的透视辅助简...