>  기사  >  웹 프론트엔드  >  Vue는 슬라이딩 스태킹 구성 요소를 구현합니다.

Vue는 슬라이딩 스태킹 구성 요소를 구현합니다.

php中世界最好的语言
php中世界最好的语言원래의
2018-04-11 16:30:122603검색

이번에는 vue에서 슬라이딩 스태킹 컴포넌트 구현에 대해 알려드리겠습니다. vue에서 슬라이딩 스태킹 컴포넌트 구현 시 주의사항은 무엇입니까? 다음은 실제 사례입니다.

머리말

안녕하세요, 탄탄(Tantan)에 대해 말씀드리자면 여러분 모두 이 프로그램에 대해 잘 알고 계시리라 생각합니다(결국 여자분들이 많죠). 탄탄의 겹겹이 쌓인 슬라이딩 부품이 브랜드를 원활하게 뒤집는 데 중요한 역할을 하는지 살펴보겠습니다. 탄탄 스태킹 컴포넌트

로 작성해보세요. 1. 기능 분석

포함된 기본 기능 사항에 대한 간략한 요약:

  • 사진 쌓기

  • 첫 번째 사진 슬라이딩


  • 조건 성공 후 슬라이드 아웃, 조건 실패 후 리바운드


  • 다음 사진은 이후 위에 쌓인다 슬라이딩 아웃


  • 경험 최적화


  • 슬라이드할 때 터치 포인트에 따라 첫 번째 이미지가 다른 각도로 오프셋됩니다.


  • 오프셋 영역에 따라 슬라이드 아웃 여부가 결정됩니다. 성공


2. 구체적인 구현

요약된 기능적 포인트를 통해 컴포넌트 구현에 대한 우리의 아이디어가 더욱 명확해질 것입니다

1.스태킹 효과

인터넷에는 쌓인 그림 효과의 예가 많이 있습니다. 구현 방법은 유사합니다. 하위 레이어의 원근감은 주로 상위 레이어에 원근감과 원점을 설정하여 얻을 수 있습니다. 하위 레이어에서 Translate3d Z축 값을 설정하는 경우 구체적인 코드는 다음과 같습니다

// 图片堆叠dom
 <!--opacity: 0 隐藏我们不想看到的stack-item层级-->
 <!--z-index: -1 调整stack-item层级"-->
<ul class="stack">
 <li class="stack-item" style="transform: translate3d(0px, 0px, 0px);opacity: 1;z-index: 10;"><img src="1.png" alt="01"></li>
 <li class="stack-item" style="transform: translate3d(0px, 0px, -60px);opacity: 1;z-index: 1"><img src="2.png" alt="02"></li>
 <li class="stack-item" style="transform: translate3d(0px, 0px, -120px);opacity: 1;z-index: 1"><img src="3.png" alt="03"></li>
 <li class="stack-item" style="transform: translate3d(0px, 0px, -180px);opacity: 0;z-index: -1"><img src="4.png" alt="04"></li>
 <li class="stack-item" style="transform: translate3d(0px, 0px, -180px);opacity: 0;z-index: -1"><img src="5.png" alt="05"></li>
</ul>
<style>
.stack {
 width: 100%;
 height: 100%;
 position: relative;
 perspective: 1000px; //子元素视距
 perspective-origin: 50% 150%; //子元素透视位置
 -webkit-perspective: 1000px;
 -webkit-perspective-origin: 50% 150%;
 margin: 0;
 padding: 0;
 }
 .stack-item{
 background: #fff;
 height: 100%;
 width: 100%;
 border-radius: 4px;
 text-align: center;
 overflow: hidden;
 }
 .stack-item img {
 width: 100%;
 display: block;
 pointer-events: none;
 }
</style>

위는 단지 정적 코드 집합입니다. 우리가 얻고자 하는 것은 vue 구성 요소이므로 먼저 구성 요소 템플릿 stack.vue를 만들어야 합니다. 템플릿에서 v-for를 사용하여 스택 노드를 순회할 수 있습니다. :style 각 항목의 스타일을 수정하는 코드는 다음과 같습니다

<template>
 <ul class="stack">
  <li class="stack-item" v-for="(item, index) in pages" :style="[transform(index)]">
  <img :src="item.src">
  </li>
 </ul>
</template>
<script>
export default {
 props: {
 // pages数据包含基础的图片数据
 pages: {
  type: Array,
  default: []
 }
 },
 data () {
 return {
  // basicdata数据包含组件基本数据
  basicdata: {
  currentPage: 0 // 默认首图的序列
  },
  // temporaryData数据包含组件临时数据
  temporaryData: {
  opacity: 1, // 记录opacity
  zIndex: 10, // 记录zIndex
  visible: 3 // 记录默认显示堆叠数visible
  }
 }
 },
 methods: {
 // 遍历样式
 transform (index) {
  if (index >= this.basicdata.currentPage) {
  let style = {}
  let visible = this.temporaryData.visible
  let perIndex = index - this.basicdata.currentPage
  // visible可见数量前滑块的样式
  if (index <= this.basicdata.currentPage + visible - 1) {
   style[&#39;opacity&#39;] = &#39;1&#39;
   style[&#39;transform&#39;] = &#39;translate3D(0,0,&#39; + -1 * perIndex * 60 + &#39;px&#39; + &#39;)&#39;
   style[&#39;zIndex&#39;] = visible - index + this.basicdata.currentPage
   style[&#39;transitionTimingFunction&#39;] = &#39;ease&#39;
   style[&#39;transitionDuration&#39;] = 300 + &#39;ms&#39;
  } else {
   style[&#39;zIndex&#39;] = &#39;-1&#39;
   style[&#39;transform&#39;] = &#39;translate3D(0,0,&#39; + -1 * visible * 60 + &#39;px&#39; + &#39;)&#39;
  }
  return style
  }
 }
 }
}
</script>

핵심 포인트

:style은 배열과 함수뿐만 아니라 객체도 바인딩할 수 있는데, 이는 탐색할 때 매우 유용합니다. 다음 단계는 첫 번째 그림을 "이동"시키는 것입니다.
2. 그림 슬라이딩

그림 슬라이딩 효과는 여러 장면에서 나타납니다. 그 원리는 터치 이벤트를 듣고 변위를 얻은 다음 Translate3D를 통해 대상 변위를 변경하는 것입니다. 따라서 우리가 달성하려는 단계는 다음과 같습니다. 터치 이벤트를 스택에 바인딩

제스처 위치 변경 값을 모니터링하고 저장
  • 첫 번째 이미지의 CSS 속성에서 Translate3D의 x, y 값을 변경


  • #### 구체적인 구현

    vue 프레임워크에서는 노드를 직접 조작하는 것이 아니라 v-on 명령을 통해 요소를 바인딩하는 것을 권장합니다. 따라서 순회를 위해 v-에 바인딩을 작성하고 인덱스를 사용하여 첫 번째 이미지인지 확인합니다. 그런 다음 :style을 사용하여 홈페이지 스타일을 수정합니다. 구체적인 코드는 다음과 같습니다.

    <template>
     <ul class="stack">
      <li class="stack-item" v-for="(item, index) in pages"
      :style="[transformIndex(index),transform(index)]"
      @touchstart.stop.capture="touchstart"
      @touchmove.stop.capture="touchmove"
      @touchend.stop.capture="touchend"
      @mousedown.stop.capture="touchstart"
      @mouseup.stop.capture="touchend"
      @mousemove.stop.capture="touchmove">
      <img :src="item.src">
      </li>
     </ul>
    </template>
    <script>
    export default {
     props: {
     // pages数据包含基础的图片数据
     pages: {
      type: Array,
      default: []
     }
     },
     data () {
     return {
      // basicdata数据包含组件基本数据
      basicdata: {
      start: {}, // 记录起始位置
      end: {}, // 记录终点位置
      currentPage: 0 // 默认首图的序列
      },
      // temporaryData数据包含组件临时数据
      temporaryData: {
      poswidth: '', // 记录位移
      posheight: '', // 记录位移
      tracking: false // 是否在滑动,防止多次操作,影响体验
      }
     }
     },
     methods: {
     touchstart (e) {
      if (this.temporaryData.tracking) {
      return
      }
      // 是否为touch
      if (e.type === 'touchstart') {
      if (e.touches.length > 1) {
       this.temporaryData.tracking = false
       return
      } else {
       // 记录起始位置
       this.basicdata.start.t = new Date().getTime()
       this.basicdata.start.x = e.targetTouches[0].clientX
       this.basicdata.start.y = e.targetTouches[0].clientY
       this.basicdata.end.x = e.targetTouches[0].clientX
       this.basicdata.end.y = e.targetTouches[0].clientY
      }
      // pc操作
      } else {
      this.basicdata.start.t = new Date().getTime()
      this.basicdata.start.x = e.clientX
      this.basicdata.start.y = e.clientY
      this.basicdata.end.x = e.clientX
      this.basicdata.end.y = e.clientY
      }
      this.temporaryData.tracking = true
     },
     touchmove (e) {
      // 记录滑动位置
      if (this.temporaryData.tracking && !this.temporaryData.animation) {
      if (e.type === 'touchmove') {
       this.basicdata.end.x = e.targetTouches[0].clientX
       this.basicdata.end.y = e.targetTouches[0].clientY
      } else {
       this.basicdata.end.x = e.clientX
       this.basicdata.end.y = e.clientY
      }
      // 计算滑动值
      this.temporaryData.poswidth = this.basicdata.end.x - this.basicdata.start.x
      this.temporaryData.posheight = this.basicdata.end.y - this.basicdata.start.y
      }
     },
     touchend (e) {
      this.temporaryData.tracking = false
      // 滑动结束,触发判断
     },
     // 非首页样式切换
     transform (index) {
      if (index > this.basicdata.currentPage) {
      let style = {}
      let visible = 3
      let perIndex = index - this.basicdata.currentPage
      // visible可见数量前滑块的样式
      if (index <= this.basicdata.currentPage + visible - 1) {
       style[&#39;opacity&#39;] = &#39;1&#39;
       style[&#39;transform&#39;] = &#39;translate3D(0,0,&#39; + -1 * perIndex * 60 + &#39;px&#39; + &#39;)&#39;
       style[&#39;zIndex&#39;] = visible - index + this.basicdata.currentPage
       style[&#39;transitionTimingFunction&#39;] = &#39;ease&#39;
       style[&#39;transitionDuration&#39;] = 300 + &#39;ms&#39;
      } else {
       style[&#39;zIndex&#39;] = &#39;-1&#39;
       style[&#39;transform&#39;] = &#39;translate3D(0,0,&#39; + -1 * visible * 60 + &#39;px&#39; + &#39;)&#39;
      }
      return style
      }
     },
     // 首页样式切换
     transformIndex (index) {
      // 处理3D效果
      if (index === this.basicdata.currentPage) {
      let style = {}
      style[&#39;transform&#39;] = &#39;translate3D(&#39; + this.temporaryData.poswidth + &#39;px&#39; + &#39;,&#39; + this.temporaryData.posheight + &#39;px&#39; + &#39;,0px)&#39;
      style[&#39;opacity&#39;] = 1
      style[&#39;zIndex&#39;] = 10
      return style
      }
     }
     }
    }
    </script>
  • 3. 조건 성공 시 슬라이드아웃, 조건 실패 시 리바운드

조건의 트리거 판단은 터치엔드/마우스업 이후에 수행됩니다. 여기서는 먼저 간단한 조건을 사용하여 판단하고 동시에 첫 번째 이미지 팝업 및 리바운드 효과를 제공합니다.

<template>
 <ul class="stack">
  <li class="stack-item" v-for="(item, index) in pages"
  :style="[transformIndex(index),transform(index)]"
  @touchmove.stop.capture="touchmove"
  @touchstart.stop.capture="touchstart"
  @touchend.stop.capture="touchend"
  @mousedown.stop.capture="touchstart"
  @mouseup.stop.capture="touchend"
  @mousemove.stop.capture="touchmove">
  <img :src="item.src">
  </li>
 </ul>
</template>
<script>
export default {
 props: {
  // pages数据包含基础的图片数据
 pages: {
  type: Array,
  default: []
 }
 },
 data () {
 return {
  // basicdata数据包含组件基本数据
  basicdata: {
  start: {}, // 记录起始位置
  end: {}, // 记录终点位置
  currentPage: 0 // 默认首图的序列
  },
  // temporaryData数据包含组件临时数据
  temporaryData: {
  poswidth: '', // 记录位移
  posheight: '', // 记录位移
  tracking: false, // 是否在滑动,防止多次操作,影响体验
  animation: false, // 首图是否启用动画效果,默认为否
  opacity: 1 // 记录首图透明度
  }
 }
 },
 methods: {
 touchstart (e) {
  if (this.temporaryData.tracking) {
  return
  }
  // 是否为touch
  if (e.type === 'touchstart') {
  if (e.touches.length > 1) {
   this.temporaryData.tracking = false
   return
  } else {
   // 记录起始位置
   this.basicdata.start.t = new Date().getTime()
   this.basicdata.start.x = e.targetTouches[0].clientX
   this.basicdata.start.y = e.targetTouches[0].clientY
   this.basicdata.end.x = e.targetTouches[0].clientX
   this.basicdata.end.y = e.targetTouches[0].clientY
  }
  // pc操作
  } else {
  this.basicdata.start.t = new Date().getTime()
  this.basicdata.start.x = e.clientX
  this.basicdata.start.y = e.clientY
  this.basicdata.end.x = e.clientX
  this.basicdata.end.y = e.clientY
  }
  this.temporaryData.tracking = true
  this.temporaryData.animation = false
 },
 touchmove (e) {
  // 记录滑动位置
  if (this.temporaryData.tracking && !this.temporaryData.animation) {
  if (e.type === 'touchmove') {
   this.basicdata.end.x = e.targetTouches[0].clientX
   this.basicdata.end.y = e.targetTouches[0].clientY
  } else {
   this.basicdata.end.x = e.clientX
   this.basicdata.end.y = e.clientY
  }
  // 计算滑动值
  this.temporaryData.poswidth = this.basicdata.end.x - this.basicdata.start.x
  this.temporaryData.posheight = this.basicdata.end.y - this.basicdata.start.y
  }
 },
 touchend (e) {
  this.temporaryData.tracking = false
  this.temporaryData.animation = true
  // 滑动结束,触发判断
  // 简单判断滑动宽度超出100像素时触发滑出
  if (Math.abs(this.temporaryData.poswidth) >= 100) {
  // 最终位移简单设定为x轴200像素的偏移
  let ratio = Math.abs(this.temporaryData.posheight / this.temporaryData.poswidth)
  this.temporaryData.poswidth = this.temporaryData.poswidth >= 0 ? this.temporaryData.poswidth + 200 : this.temporaryData.poswidth - 200
  this.temporaryData.posheight = this.temporaryData.posheight >= 0 ? Math.abs(this.temporaryData.poswidth * ratio) : -Math.abs(this.temporaryData.poswidth * ratio)
  this.temporaryData.opacity = 0
  // 不满足条件则滑入
  } else {
  this.temporaryData.poswidth = 0
  this.temporaryData.posheight = 0
  }
 },
 // 非首页样式切换
 transform (index) {
  if (index > this.basicdata.currentPage) {
  let style = {}
  let visible = 3
  let perIndex = index - this.basicdata.currentPage
  // visible可见数量前滑块的样式
  if (index <= this.basicdata.currentPage + visible - 1) {
   style[&#39;opacity&#39;] = &#39;1&#39;
   style[&#39;transform&#39;] = &#39;translate3D(0,0,&#39; + -1 * perIndex * 60 + &#39;px&#39; + &#39;)&#39;
   style[&#39;zIndex&#39;] = visible - index + this.basicdata.currentPage
   style[&#39;transitionTimingFunction&#39;] = &#39;ease&#39;
   style[&#39;transitionDuration&#39;] = 300 + &#39;ms&#39;
  } else {
   style[&#39;zIndex&#39;] = &#39;-1&#39;
   style[&#39;transform&#39;] = &#39;translate3D(0,0,&#39; + -1 * visible * 60 + &#39;px&#39; + &#39;)&#39;
  }
  return style
  }
 },
 // 首页样式切换
 transformIndex (index) {
  // 处理3D效果
  if (index === this.basicdata.currentPage) {
  let style = {}
  style[&#39;transform&#39;] = &#39;translate3D(&#39; + this.temporaryData.poswidth + &#39;px&#39; + &#39;,&#39; + this.temporaryData.posheight + &#39;px&#39; + &#39;,0px)&#39;
  style[&#39;opacity&#39;] = this.temporaryData.opacity
  style[&#39;zIndex&#39;] = 10
  if (this.temporaryData.animation) {
   style[&#39;transitionTimingFunction&#39;] = &#39;ease&#39;
   style[&#39;transitionDuration&#39;] = 300 + &#39;ms&#39;
  }
  return style
  }
 }
 }
}
</script>

4. 슬라이드하면 다음 사진이 위에 쌓이게 됩니다

리스태킹은 컴포넌트의 마지막 기능이자 가장 중요하고 복잡한 기능이기도 합니다. 우리 코드에서 스택 항목의 정렬은 바인딩 스타일의 변형 함수와 변형에 따라 달라집니다. 함수에서 결정된 조건은 currentPage를 변경하고 재스택을 완료하려면 +1해야 합니까? ?

대답은 그렇게 간단하지 않습니다. 슬라이드 아웃은 300ms가 소요되는 애니메이션 효과이고 currentPage 변경으로 인한 재배열이 즉시 변경되어 애니메이션 진행을 방해하기 때문입니다. 따라서 변환 함수의 정렬 조건을 먼저 수정한 후 currentPage를 변경해야 합니다.

#### 구체적인 구현

변환 함수 정렬 조건 수정

Let currentPage+

  • on

    TransitionEnd 이벤트

    추가, 슬라이드 아웃 종료 후 스택 목록으로 재배치

  • 코드는 다음과 같습니다:

    <template>
     <ul class="stack">
      <li class="stack-item" v-for="(item, index) in pages"
      :style="[transformIndex(index),transform(index)]"
      @touchmove.stop.capture="touchmove"
      @touchstart.stop.capture="touchstart"
      @touchend.stop.capture="touchend"
      @mousedown.stop.capture="touchstart"
      @mouseup.stop.capture="touchend"
      @mousemove.stop.capture="touchmove"
      @webkit-transition-end="onTransitionEnd"
      @transitionend="onTransitionEnd"
      >
      <img :src="item.src">
      </li>
     </ul>
    </template>
    <script>
    export default {
     props: {
     // pages数据包含基础的图片数据
     pages: {
      type: Array,
      default: []
     }
     },
     data () {
     return {
      // basicdata数据包含组件基本数据
      basicdata: {
      start: {}, // 记录起始位置
      end: {}, // 记录终点位置
      currentPage: 0 // 默认首图的序列
      },
      // temporaryData数据包含组件临时数据
      temporaryData: {
      poswidth: '', // 记录位移
      posheight: '', // 记录位移
      lastPosWidth: '', // 记录上次最终位移
      lastPosHeight: '', // 记录上次最终位移
      tracking: false, // 是否在滑动,防止多次操作,影响体验
      animation: false, // 首图是否启用动画效果,默认为否
      opacity: 1, // 记录首图透明度
      swipe: false // onTransition判定条件
      }
     }
     },
     methods: {
     touchstart (e) {
      if (this.temporaryData.tracking) {
      return
      }
      // 是否为touch
      if (e.type === 'touchstart') {
      if (e.touches.length > 1) {
       this.temporaryData.tracking = false
       return
      } else {
       // 记录起始位置
       this.basicdata.start.t = new Date().getTime()
       this.basicdata.start.x = e.targetTouches[0].clientX
       this.basicdata.start.y = e.targetTouches[0].clientY
       this.basicdata.end.x = e.targetTouches[0].clientX
       this.basicdata.end.y = e.targetTouches[0].clientY
      }
      // pc操作
      } else {
      this.basicdata.start.t = new Date().getTime()
      this.basicdata.start.x = e.clientX
      this.basicdata.start.y = e.clientY
      this.basicdata.end.x = e.clientX
      this.basicdata.end.y = e.clientY
      }
      this.temporaryData.tracking = true
      this.temporaryData.animation = false
     },
     touchmove (e) {
      // 记录滑动位置
      if (this.temporaryData.tracking && !this.temporaryData.animation) {
      if (e.type === 'touchmove') {
       this.basicdata.end.x = e.targetTouches[0].clientX
       this.basicdata.end.y = e.targetTouches[0].clientY
      } else {
       this.basicdata.end.x = e.clientX
       this.basicdata.end.y = e.clientY
      }
      // 计算滑动值
      this.temporaryData.poswidth = this.basicdata.end.x - this.basicdata.start.x
      this.temporaryData.posheight = this.basicdata.end.y - this.basicdata.start.y
      }
     },
     touchend (e) {
      this.temporaryData.tracking = false
      this.temporaryData.animation = true
      // 滑动结束,触发判断
      // 简单判断滑动宽度超出100像素时触发滑出
      if (Math.abs(this.temporaryData.poswidth) >= 100) {
      // 最终位移简单设定为x轴200像素的偏移
      let ratio = Math.abs(this.temporaryData.posheight / this.temporaryData.poswidth)
      this.temporaryData.poswidth = this.temporaryData.poswidth >= 0 ? this.temporaryData.poswidth + 200 : this.temporaryData.poswidth - 200
      this.temporaryData.posheight = this.temporaryData.posheight >= 0 ? Math.abs(this.temporaryData.poswidth * ratio) : -Math.abs(this.temporaryData.poswidth * ratio)
      this.temporaryData.opacity = 0
      this.temporaryData.swipe = true
      // 记录最终滑动距离
      this.temporaryData.lastPosWidth = this.temporaryData.poswidth
      this.temporaryData.lastPosHeight = this.temporaryData.posheight
      // currentPage+1 引发排序变化
      this.basicdata.currentPage += 1
      // currentPage切换,整体dom进行变化,把第一层滑动置零
      this.$nextTick(() => {
       this.temporaryData.poswidth = 0
       this.temporaryData.posheight = 0
       this.temporaryData.opacity = 1
      })
      // 不满足条件则滑入
      } else {
      this.temporaryData.poswidth = 0
      this.temporaryData.posheight = 0
      this.temporaryData.swipe = false
      }
     },
     onTransitionEnd (index) {
      // dom发生变化后,正在执行的动画滑动序列已经变为上一层
      if (this.temporaryData.swipe && index === this.basicdata.currentPage - 1) {
      this.temporaryData.animation = true
      this.temporaryData.lastPosWidth = 0
      this.temporaryData.lastPosHeight = 0
      this.temporaryData.swipe = false
      }
     },
     // 非首页样式切换
     transform (index) {
      if (index > this.basicdata.currentPage) {
      let style = {}
      let visible = 3
      let perIndex = index - this.basicdata.currentPage
      // visible可见数量前滑块的样式
      if (index <= this.basicdata.currentPage + visible - 1) {
       style[&#39;opacity&#39;] = &#39;1&#39;
       style[&#39;transform&#39;] = &#39;translate3D(0,0,&#39; + -1 * perIndex * 60 + &#39;px&#39; + &#39;)&#39;
       style[&#39;zIndex&#39;] = visible - index + this.basicdata.currentPage
       style[&#39;transitionTimingFunction&#39;] = &#39;ease&#39;
       style[&#39;transitionDuration&#39;] = 300 + &#39;ms&#39;
      } else {
       style[&#39;zIndex&#39;] = &#39;-1&#39;
       style[&#39;transform&#39;] = &#39;translate3D(0,0,&#39; + -1 * visible * 60 + &#39;px&#39; + &#39;)&#39;
      }
      return style
      // 已滑动模块释放后
      } else if (index === this.basicdata.currentPage - 1) {
      let style = {}
      // 继续执行动画
      style[&#39;transform&#39;] = &#39;translate3D(&#39; + this.temporaryData.lastPosWidth + &#39;px&#39; + &#39;,&#39; + this.temporaryData.lastPosHeight + &#39;px&#39; + &#39;,0px)&#39;
      style[&#39;opacity&#39;] = &#39;0&#39;
      style[&#39;zIndex&#39;] = &#39;-1&#39;
      style[&#39;transitionTimingFunction&#39;] = &#39;ease&#39;
      style[&#39;transitionDuration&#39;] = 300 + &#39;ms&#39;
      return style
      }
     },
     // 首页样式切换
     transformIndex (index) {
      // 处理3D效果
      if (index === this.basicdata.currentPage) {
      let style = {}
      style[&#39;transform&#39;] = &#39;translate3D(&#39; + this.temporaryData.poswidth + &#39;px&#39; + &#39;,&#39; + this.temporaryData.posheight + &#39;px&#39; + &#39;,0px)&#39;
      style[&#39;opacity&#39;] = this.temporaryData.opacity
      style[&#39;zIndex&#39;] = 10
      if (this.temporaryData.animation) {
       style[&#39;transitionTimingFunction&#39;] = &#39;ease&#39;
       style[&#39;transitionDuration&#39;] = 300 + &#39;ms&#39;
      }
      return style
      }
     }
     }
    }
    </script>
    알았어~ 위의 4가지 단계를 완료하면 구성요소 쌓기의 기본 기능이 구현되었습니다. 와서 그 효과를 확인해 보세요

    이 기사의 사례를 읽으신 후 방법을 마스터하셨다고 생각합니다. 더 흥미로운 정보를 보려면 PHP 중국어 웹사이트의 다른 관련 기사를 주목하세요!

    추천 자료:

    Native가 fetch를 사용하여 이미지 업로드 기능을 구현하는 방법

    vue.js가 배열 위치를 이동하고 뷰를 실시간으로 업데이트합니다

위 내용은 Vue는 슬라이딩 스태킹 구성 요소를 구현합니다.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.