小秃子 发表于 2019-12-27 14:10:33

swiper创建

that.swp = new Swiper(".swiper-container", {
                loop: false,
                on: {
                  slideChangeTransitionStart: function() {
                        that.showback = false;
                        if (program[this.realIndex].type === 1) {
                            let element;
                            element = that.el.nativeElement.querySelectorAll(
                              "#dplayer" + program[this.realIndex].id
                            )[0];
                            if (!that.dPlayers[this.activeIndex]) {
                              console.log("创建播放器之前", this.activeIndex);
                              that.initVideo(
                                    element,
                                    program[this.realIndex],
                                    this.activeIndex
                              );
                            }
                        }
                  },
                  slideNextTransitionEnd: function() {
                        that.slideNext(this.activeIndex);
                  },
                  slidePrevTransitionEnd: function() {
                        that.slidePrev(this.activeIndex);
                  },
                  click: function() {
                        that.click(this.realIndex, this.activeIndex);
                  }
                }
            });

我写了一个swiper的初始化打印this.swiper出来的确是一个数组导致使用this.swp.slidePrev()报错如何解决这种问题



页: [1]
查看完整版本: swiper创建