Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swiper组件h5端高度设置不生效 #1191

Closed
nsyujian opened this issue Nov 20, 2018 · 4 comments
Closed

Swiper组件h5端高度设置不生效 #1191

nsyujian opened this issue Nov 20, 2018 · 4 comments

Comments

@nsyujian
Copy link

问题描述
Swiper组件h5端高度设置不生效

复现步骤

  render() {
    const {medias} = this.props
    const {index} = this.state
    return (
      <View className='container'>
        <Swiper
          className='swiper'
          onChange={this.onChange}
        >
          {medias.map((item, index) => {
            return (
              <SwiperItem key={index} className='swiper-item'>
                {item.typeId === 1
                  ? <Image className='swiper-media' src={item.url} mode='aspectFill' />
                  : <Video className='swiper-media' src={item.url} poster={item.coverUrl} />
                }
              </SwiperItem>
            )
          })}
        </Swiper>
        <View className='indicator'>
          <Text className='indicator-text'>
            {`${index + 1}/${medias.length}`}
          </Text>
        </View>
      </View>
    )
  }
.container {
  position: relative;
  height: 750px;
  width: 100%;
}

.swiper {
  width: 100%;
  height: 100%;
}

.swiper-item {
  width: 100%;
  height: 100%;
}

试过都设置固定高度也不生效

期望行为
高度可以设置750px

报错信息
SwiperItem 高度一直为150px

系统信息

  • 操作系统: [macOS]
  • Taro 版本 [ v.1.1.8]
  • Node.js 版本 [e.g. v8.11.1]
  • 报错平台 [h5]
@taro-bot
Copy link

taro-bot bot commented Nov 20, 2018

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@rmlzy
Copy link

rmlzy commented Jan 14, 2019

嗨, 我遇到了同样的问题(v1.2.4), 请问你是怎么解决的?

在h5端SwiperItem 始终为150px

@jinjinjin0731
Copy link
Contributor

@rmlzy 默认高度为 150 需要不同高度请自行在 swiper 上添加 css 相关样式

@GogoWwz
Copy link

GogoWwz commented Jun 28, 2021

@rmlzy 默认高度为 150 需要不同高度请自行在 swiper 上添加 css 相关样式

请问下如果高度不确定的情况怎么设置?
只能动态计算绑定吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants