swiper高度中无法占满屏幕,只能给值?

小程序 文章 2021-03-29 09:21 507 0 全屏看文

AI助手支持GPT4.0

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

回答:

Brother斌🎈:

动态计算swiper的高度就可以了,在onReady里面写上

wx.getSystemInfoSync().windowHeight* (750 / wx.getSystemInfoSync().windowWidth)-其他区域的高度


鲤子:

上拉加载为啥要用swiper,scroll-view不行??swiper高度要指定的,不会随内容变化高度的,可以用接口获取容器内容高度然后动态改变就行了。

维她命系:

image 高度必须设置,否则就是默认的高度值,swiper 位置一般都是固定高度,如果需要动态变化,可以检测图片 bindload 事件,动态获取图片高度值。

锖兔:图片我给了高度。但是swipr中还是只能给固定高度
维她命系:是展示视频吧?可以试试这个组件
https://developers.weixin.qq.com/miniprogram/dev/extended/component-plus/video-swiper.html
如果是展示图片,可以获取当前设备的高度,动态设置到swiper高度上。
锖兔:不是的,哥,我是想做一个电子书书架列表,是数据库渲染的,我还实现上拉加载更多的数据,但是我只能设定固定高度,高度太低不够加载,高度太好触发不了上拉触底,就很难受
维她命系:没太明白是怎么用的

-EOF-

AI助手支持GPT4.0