Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue2.0 变成ref以后 _createLoop用不了了 #23

Open
wjhcc2018 opened this issue Aug 8, 2017 · 0 comments
Open

Vue2.0 变成ref以后 _createLoop用不了了 #23

wjhcc2018 opened this issue Aug 8, 2017 · 0 comments

Comments

@wjhcc2018
Copy link

wjhcc2018 commented Aug 8, 2017

请问为什么改成ref以后,

 this.$nextTick(function () {
    this.setPage(this.currentPage, true)
    this.slideEls = this.$refs.swiperWrap.children;
    this._createLoop()
  })
<div class="vswiper-wrap" ref="swiperWrap" :style="{
        'transform' : 'translate3d(' + translateX + 'px,' + translateY + 'px, 0)',
        'transition-duration': transitionDuration + 'ms'
     }" @transitionend="_onTransitionEnd">
    <slot></slot>
</div>
_createLoop () {
  var propName = this.isHorizontal() ? 'clientWidth' : 'clientHeight'
  var swiperWrapEl = this.$refs.swiperWrap
  if(swiperWrapEl[0]){
    var duplicateFirstChild = swiperWrapEl[0].cloneNode(true)
    var duplicateLastChild = swiperWrapEl.lastElementChild.cloneNode(true)
    swiperWrapEl.insertBefore(duplicateLastChild, swiperWrapEl.firstElementChild)
    swiperWrapEl.appendChild(duplicateFirstChild)
    this.translateOffset = -duplicateLastChild[propName]
  }
}

loop 为true就用不了了呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant