加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

基于mpvue的小程序swiper类3d轮播

发布时间:2020-12-14 19:22:24 所属栏目:资源 来源:网络整理
导读:前言 功能:实现类3d轮播,切换效果为放大缩小? 技术: 使用 mpvue框架,用小程序swiper组件以及小程序Animation动画对象 项目地址:?https://github.com/gzz0204/mpvue-swiper 效果: 演示效果图 一、结构 小程序swiper? 改为mpvue的写法。 设置previous-mar

前言

功能:实现类3d轮播,切换效果为放大缩小?
技术: 使用 mpvue框架,用小程序swiper组件以及小程序Animation动画对象

项目地址:?https://github.com/gzz0204/mpvue-swiper

效果:

演示效果图

一、结构

小程序swiper?
改为mpvue的写法。

设置previous-margin和next-margin来漏出两边的模块?
设置circular使轮播无限循环

绑定change事件,自定义handleChange方法获取当前swiper的index

小程序swiper文档

  1. <template>
  2. <div class="home_wrap">
  3. :previous-margin"previousMargin"
  4. circular"circular"
  5. <blockv-for"(item,index) in datalist" :key"index">
  6. "curIndex===index ? 'active_item' : 'item'"animation"index == curIndex ? animationData : animationData2">
  7. <Carddata"item" />
  8. </swiper-item>
  9. </swiper>
  10. "swiper_dot_wrap" <ul>
  11. ></li>
  12. </div>
  13. 二、js

    import Card from '@/components/home_card'
  14. data (){
  15. curIndex: 0,
  16. coverImg 'http://n.sinaimg.cn/sinacn20118/201/w1080h721/20190119/3311-hrvcwnk7953342.jpg'
  17. 'https://lh3.googleusercontent.com/IU9_NYevRO-fFjiH_hhjuxTOuDhG3cmMCWNOlnz2TBoG9jICiZevHGC0eJmvsrUwUAtbeFc=s128'
  18. '圣彼得堡是另一个阿姆斯特丹'
  19. previousMargin'63rpx' animationData2{}// 卡片缩小动画
  20. components{
  21. methods{
  22. changeActive()
  23. changeNormal var animation2 wxcreateAnimation({
  24. animation2 animation2
  25. changeActive animation animation animation
  26. }
  27. 三、样式

    home_swiper {
  28. position relative;
  29. height876rpx!important;
  30. }
  31. transform scale);
  32. opacity;
  33. active_item);
  34. // 指示点
  35. top106rpx right65rpx15rpx ulfloat right overflow hidden;
  36. left;
  37. 2rpx solid #b99c6d;
  38. &:lastchild{
  39. }
  40. }
  41. 子组件card

    <template>
  42. "card">
  43. "img_wrap">
  44. </div>
  45. "cont_wrap">
  46. "title_wrap">
  47. >
  48. "desc">{{desc}}</>
  49. </template<script>
  50. }
  51. scriptstyle lang scoped890rpxcard position;
  52. border7rpxactive_item /* banner */
  53. /* 图片 */
  54. 399rpx7rpx0 zindex5 opacity0.7/* 标题出处 */
  55. box color#b99c6d;
  56. fontsize30rpx lineheight35rpx70rpx padding// 描述