tab1.page.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
  2. import Swiper from 'swiper';
  3. @Component({
  4. selector: 'app-tab1',
  5. templateUrl: 'tab1.page.html',
  6. styleUrls: ['tab1.page.scss']
  7. })
  8. export class Tab1Page implements OnInit {
  9. selectedSegment: string = 'explore';
  10. @ViewChild("slide1Comp") slide1Comp:ElementRef |undefined
  11. constructor() {}
  12. ngOnInit() {
  13. // 延迟500毫秒加载
  14. setTimeout(() => {
  15. this.initSwiper();
  16. }, 500);
  17. }
  18. // 初始化轮播图
  19. slide1:Swiper|undefined
  20. initSwiper(){
  21. console.log(this.slide1Comp)
  22. this.slide1 = new Swiper(this.slide1Comp?.nativeElement, {
  23. loop:true,
  24. autoplay:{
  25. delay:500,
  26. },
  27. mousewheel: {
  28. forceToAxis: true,
  29. },
  30. pagination:{
  31. el:".swiper-pagination",
  32. clickable:true
  33. }
  34. });
  35. }
  36. segmentChanged(event: CustomEvent) {
  37. this.selectedSegment = event.detail.value;
  38. }
  39. // 在此处定义和初始化数据
  40. contentList = [
  41. { image: 'https://img.zcool.cn/community/01df555d65edcea8012187f4e41c2f.jpg@2o.jpg', title: '示例标题1', user: '用户A', likes: 10, comments: 5, tags: '标签1, 标签2' },
  42. { image: 'https://img.zcool.cn/community/01df555d65edcea8012187f4e41c2f.jpg@2o.jpg', title: '示例标题2', user: '用户B', likes: 20, comments: 8, tags: '标签3, 标签4' },
  43. // 添加更多示例数据
  44. ];
  45. videos: { videoUrl: string, title: string, description: string }[] = [
  46. {
  47. videoUrl: 'assets/videos/video2.mp4',
  48. title: '房屋装修设计指南',
  49. description: '了解如何打造理想的家居装修风格'
  50. },
  51. {
  52. videoUrl: 'assets/videos/video2.mp4',
  53. title: '家具选购攻略',
  54. description: '挑选适合你家的家具,打造舒适空间'
  55. },
  56. {
  57. videoUrl: 'assets/videos/video3.mp4',
  58. title: '客厅装饰灵感',
  59. description: '打造温馨舒适的客厅装饰'
  60. },
  61. {
  62. videoUrl: 'assets/videos/video4.mp4',
  63. title: '卧室设计技巧',
  64. description: '掌握卧室设计的实用技巧'
  65. },
  66. {
  67. videoUrl: 'assets/videos/video5.mp4',
  68. title: '厨房装修实例',
  69. description: '欣赏不同风格的厨房装修案例'
  70. },
  71. {
  72. videoUrl: 'assets/videos/video6.mp4',
  73. title: '阳台花园布置',
  74. description: '打造美丽的阳台花园'
  75. },
  76. {
  77. videoUrl: 'assets/videos/video7.mp4',
  78. title: '书房设计灵感',
  79. description: '打造宁静的读书空间'
  80. },
  81. {
  82. videoUrl: 'assets/videos/video8.mp4',
  83. title: '浴室装修技巧',
  84. description: '打造舒适的浴室空间'
  85. },
  86. {
  87. videoUrl: 'assets/videos/video9.mp4',
  88. title: '家居风水指南',
  89. description: '了解家居风水的重要性'
  90. },
  91. {
  92. videoUrl: 'assets/videos/video10.mp4',
  93. title: '家庭影院布置',
  94. description: '打造私人家庭影院'
  95. }
  96. // 可以根据需要添加更多视频数据
  97. ];
  98. }