import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';

import Swiper from 'swiper';

@Component({
  selector: 'app-slider',
  templateUrl: './slider.page.html',
  styleUrls: ['./slider.page.scss'],
})
export class SliderPage implements OnInit {
  @ViewChild("slide1Comp") slide1Comp:ElementRef |undefined
  constructor() { }

  ngOnInit() {
    // 延迟500毫秒加载
    setTimeout(() => {
      this.initSwiper();
    }, 500);
  }

  // 初始化轮播图
  slide1:Swiper|undefined
  initSwiper(){
    console.log(this.slide1Comp)
    this.slide1 = new Swiper(this.slide1Comp?.nativeElement, {
      loop:true,
      autoplay:{
        delay:500,
      },
      mousewheel: {
        forceToAxis: true,
      },
      pagination:{
        el:".swiper-pagination",
        clickable:true
      }
    });
  }

}
