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

import Swiper from 'swiper';


@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss']
})
export class Tab1Page implements OnInit {

  selectedSegment: string = 'explore';
  @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
      }
    });
  }


  segmentChanged(event: CustomEvent) {
    this.selectedSegment = event.detail.value;
  }

  // 在此处定义和初始化数据
  contentList = [
    { image: 'https://img.zcool.cn/community/01df555d65edcea8012187f4e41c2f.jpg@2o.jpg', title: '示例标题1', user: '用户A', likes: 10, comments: 5, tags: '标签1, 标签2' },
    { image: 'https://img.zcool.cn/community/01df555d65edcea8012187f4e41c2f.jpg@2o.jpg', title: '示例标题2', user: '用户B', likes: 20, comments: 8, tags: '标签3, 标签4' },
    // 添加更多示例数据
  ];
  




}


