index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. define([
  2. 'swiper',
  3. 'text!./index.html',
  4. 'css!./index.css'
  5. ], function(Swiper, html) {
  6. return {
  7. props: {
  8. advertList: {
  9. type: Array,
  10. default: function () {
  11. return [];
  12. }
  13. }
  14. },
  15. data: function () {
  16. return {
  17. swiperOptions: {
  18. autoplay: true,
  19. loop: true,
  20. pagination: {
  21. el: '.advert-pagination'
  22. },
  23. uniqueNavElements: false
  24. }
  25. };
  26. },
  27. mounted: function () {
  28. this.$nextTick(function () {
  29. this.swiper7 = new Swiper('#swiper7', this.swiperOptions);
  30. });
  31. },
  32. methods: {
  33. advertClick: function () {
  34. var url = this.swiper7.clickedSlide.dataset.url;
  35. if (url.indexOf('http') === -1 || url.indexOf('http')) {
  36. return;
  37. }
  38. window.location = url;
  39. }
  40. },
  41. template: html
  42. };
  43. });