[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 671 views
2

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尺寸未设置

3

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

5

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

2

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

8

已在 1.5.0-beta2 版本优化

6

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