banner.js 774 B

12345678910111213141516171819202122232425262728293031
  1. import {getDataSet, getEventParam} from "../../utils/utils";
  2. Component({
  3. externalClasses: ['banner-container', 'banner-img'],
  4. properties: {
  5. // imgList 必须存在url 显示图片
  6. imgList: Array,
  7. imgWidth: String,
  8. imgHeight: String,
  9. imgRadius: String
  10. },
  11. data: {
  12. current:0,
  13. currentIndex: 0,
  14. autoplay:true
  15. },
  16. methods: {
  17. swiperChange(e) {
  18. this.setData({
  19. currentIndex: getEventParam(e, 'current')
  20. })
  21. },
  22. onTap(e) {
  23. const index = getDataSet(e, "index");
  24. const imgList = this.data.imgList
  25. this.triggerEvent('banner', {
  26. item: imgList[index]
  27. })
  28. },
  29. },
  30. })