我自定义了一个滑动组件,然后在插槽中写自己代码。但是发现高度只能给固定值,无法写100%,改为100vh之后就无法上下滑动,请问该如何解决
swiper高度中无法占满屏幕,只能给值?The swiper height can't fill the screen, can only give value?
swiper高度中无法占满屏幕,只能给值?我自定义了一个滑动组件,然后在插槽中写自己代码。但是发现高度只能给固定值,无法写100%,改为100vh之后就无法上下滑动,请问该如何解决
I customize a slider component and write my own code in the slot. However, it is found that the height can only be given a fixed value and cannot be written 100%. After changing to 100vh, it cannot slide up and down. How can I solve this problem
回答:
上拉加载为啥要用swiper,scroll-view不行??swiper高度要指定的,不会随内容变化高度的,可以用接口获取容器内容高度然后动态改变就行了。
image 高度必须设置,否则就是默认的高度值,swiper 位置一般都是固定高度,如果需要动态变化,可以检测图片 bindload 事件,动态获取图片高度值。
动态计算swiper的高度就可以了,在onReady里面写上
wx.getSystemInfoSync().windowHeight* (750 / wx.getSystemInfoSync().windowWidth)-其他区域的高度