// 使用 wx.createAnimation API 示例 const animation = wx.createAnimation({ duration: 300, timingFunction: 'ease-out' }) animation.opacity(0).translateY(20).step() this.setData({ animationData: animation.export() })
/* 自定义导航切换动画 */ .page-enter { transform: translateX(100%); } .page-enter-active { transition: transform 0.3s ease; }2. 加载状态创意呈现
// 点击波纹效果 handleTap(e) { const { x, y } = e.detail this.setData({ rippleX: x, rippleY: y }) setTimeout(() => this.setData({ rippleX: null }), 600) }
三、 性能优化关键指标
优化方向
具体措施
预期效果
图片资源
使用SVG代替PNG动画
体积减少70%+
渲染层级
控制`z-index`,减少重叠区域重绘
渲染耗时降低40%
动画销毁
页面隐藏时停止后台动画
内存占用下降30%
帧率监控
使用性能面板监测FPS
确保≥50帧流畅体验
onTouchMove(e) { const deltaY = e.touches[0].clientY - this.startY this.animation.translateY(deltaY).step() this.setData({ dragAnimation: this.animation.export() }) }
.card { transform: perspective(800px) rotateY(15deg); transition: transform 0.4s; }