index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // nova-tourism/components/home/index.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. },
  8. /**
  9. * 组件的初始数据
  10. */
  11. data: {
  12. // 轮播图数组
  13. imageUrls: ['https://tse4-mm.cn.bing.net/th/id/OIP-C.3r1vguZyWFUJ80A2Nf2k3AHaEK?rs=1&pid=ImgDetMain', 'https://ts1.cn.mm.bing.net/th/id/R-C.9881613a29f26488b40938427aa585e4?rik=fim4XvDejjHE%2fQ&riu=http%3a%2f%2fn.sinaimg.cn%2fsinakd20220516ac%2f797%2fw2048h1149%2f20220516%2fb0aa-5aca29fe2dfa69c385118bbc74d039de.jpg&ehk=tzq%2bJP6uMipI0aIHY3bMSVO7lS7ZQM6TKMlwZ5CFP4s%3d&risl=&pid=ImgRaw&r=0', 'https://pic3.zhimg.com/v2-5fb13110e1de13d4c11e6e7f5b8026da_r.jpg', 'https://desk-fd.zol-img.com.cn/t_s960x600c5/g5/M00/02/04/ChMkJ1bKyEyIMaKUAAhskHwWGqUAALIAAM2KsIACGyo249.jpg'],
  14. index: 1,
  15. //卡片数组
  16. cardarr:[1,2,3,4,5,6,7]
  17. },
  18. lifetimes: {
  19. detached: function () {
  20. // 在组件实例被从页面节点树移除时执行
  21. },
  22. attached: async function () {
  23. // 在组件实例进入页面节点树时执行
  24. },
  25. },
  26. /**
  27. * 组件的方法列表
  28. */
  29. methods: {
  30. //随轮播图变化而变化
  31. onSwiperChange: function (event) {
  32. const currentIndex = event.detail.current; // 获取当前索引
  33. this.setData({
  34. index: currentIndex + 1
  35. })
  36. }
  37. }
  38. })