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有透视的吗!wp... hhpoker有透视的吗!wpk辅助插件(透视)技巧-切实教你存在有挂运hhpoker有透视的吗辅助...
透视揭幕!epoker免费透视... 透视揭幕!epoker免费透视脚本(透视)wepoker祈福有用吗,教程指引(真的有挂)-哔哩哔哩1...
wepoker辅助插件功能!w... wepoker辅助插件功能!wepoker辅助器激活码(透视)教程-确实专业是真的挂1、任何wepo...
透视详细!wepoker私人局... 透视详细!wepoker私人局俱乐部怎么进(透视)wpk软件是正规的吗,教程学习(有挂分析)-哔哩哔...
we poker辅助器!hhp... we poker辅助器!hhpoker可以控制牌吗(透视)器-确实曝光存在有挂1.hhpoker可以...
透视解密!wepoker线上大... 透视解密!wepoker线上大神(透视)aapoker透视脚本入口,教程窍门(确实有挂)-哔哩哔哩;...
pokemmo修改器手机版!f... pokemmo修改器手机版!fishpoker透视(透视)器-竟然必备是有挂1、pokemmo修改器...
透视详细!wepoker有没有... 透视详细!wepoker有没有挂(透视)wpk有那种辅助吗,教程积累(有挂透明挂)-哔哩哔哩wpk有...
拱趴大菠萝开挂方法!竞技联盟透... 拱趴大菠萝开挂方法!竞技联盟透视(透视)插件-确实总结真的有挂暗藏猫腻,小编详细说明拱趴大菠萝开挂方...
透视开挂!hhpoker德州挂... 透视开挂!hhpoker德州挂真的有吗(透视)约局吧开挂神器是真的吗,教程模板(有挂工具)-哔哩哔哩...