[youzan/vant]van-swipe切换路由后再回来,van-swipe-item的宽度变得很小,内容溢出(switches routes and comes back, the width of van-swipe-item becomes very small and content overflows)

2024-05-22 341 views
6

van-swipe切换路由后再回来,van-swipe-item的宽度变得很小,内容溢出

如下: image 代码 image

Environment

  • Device: macbook pro
  • Browser: chrome
  • Vant Version: ^1.1.12

Reproduce van-swipe切换路由后再回来,van-swipe-item的宽度变得很小,内容溢出,觉得是切换路由回来需要再次初始化swipe,但是API没有swipe初始化的事件

回答

3

能否提供一下 jsfiddle 呢

2

@chenjiahan 遇到类似情况,补充:可能是开了keep-alive,van-swiper没有重新init,swper-item尺寸未设置

2

暂时解决方法:activated () { swipeRef.initialize() }

1

@caixiangzhou 谢谢,可以的,it's work,thx @chenjiahan 用caixiangzhou提供的办法解决了Solve,thx

5

下个版本会在 activated 后执行一次 initialize,以避免这个问题

6

已在 1.5.0-beta2 版本优化

9

@chenjiahan OK,thx, it's very effective!