Flex 弹性布局H5和小程序端显示不一致



  • H5端显示效果如下:
    h5.png

    小程序端显示效果如下:

    xcx.png
    jsx文件如下:

      render () {
        return (
          <View className="at-row goods-item">
            <View className='at-col  at-col-5 goods-cover'>
              <Image style='width:100% ;height:100%' src='https://t00img.yangkeduo.com/goods/images/2018-08-17/af67bf771ceb52d2510d3b03c7de4ad7.jpeg'></Image>
            </View>
            <View className='at-col at-col-7  goods-info'>
              <View className='goods-title'> 国民老式纯棉床单单件双人单人全棉老上海加厚老粗布怀旧被单单件 </View>
              <View className='goods-tags'>
                <AtTag type='primary' size='small'>标签</AtTag>
                <AtTag size='small'>标签</AtTag></View>
              <View className='goods-attr'></View>
    
              <View className='goods-price'><View className='mark'>¥</View><View className='num'>33.5</View></View>
              <View className='line' />
            </View>
          </View>
        );
      }
    

    scss文件如下:

    .goods-item {
      height: 250px;
      margin-bottom: 10px;
    
      .goods-cover {
        height: 100%;
      }
    
      .goods-info {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        padding-left: 20px;
        height: 100%;
    
        .goods-title {
          width: 100%;
          height: 85px;
          line-height: 43px;
          white-space: pre-line;
          word-wrap: break-word;
          overflow: hidden;
          word-break: break-all;
        }
        .goods-tags {
          width: 100%;
          padding: 10px 0;
          .at-tag {
            margin: 0 10px;
          }
        }
    
        .goods-price {
          display: flex;
          flex-wrap: nowrap;
          align-items: flex-end;
          width: 100%;
          line-height: 40px;
          color: #e22d24;
    
          .mark {
            font-size: 24px;
          }
          .num {
            font-size: 36px;
          }
        }
    
        .line {
          width: 100%;
          border-bottom: 1px solid #f4f4f4;
        }
      }
    }
    
    

    新手刚接触,请大佬们指点一二,万分感谢!



  • @jayleco_mFlex 弹性布局H5和小程序端显示不一致 中说:

    .goods-item {
    height: 250px;
    margin-bottom: 10px;

    .goods-cover {
    height: 100%;
    }

    .goods-info {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    padding-left: 20px;
    height: 100%;

    .goods-title {
      width: 100%;
      height: 85px;
      line-height: 43px;
      white-space: pre-line;
      word-wrap: break-word;
      overflow: hidden;
      word-break: break-all;
    }
    .goods-tags {
      width: 100%;
      padding: 10px 0;
      .at-tag {
        margin: 0 10px;
      }
    }
    
    .goods-price {
      display: flex;
      flex-wrap: nowrap;
      align-items: flex-end;
      width: 100%;
      line-height: 40px;
      color: #e22d24;
    
      .mark {
        font-size: 24px;
      }
      .num {
        font-size: 36px;
      }
    }
    
    .line {
      width: 100%;
      border-bottom: 1px solid #f4f4f4;
    }
    

    }
    }

    2d7daae0-b7aa-4858-af36-ef5e1bce8696-image.png

    看起来你的代码木有给全,并不能复现问题哦。
    猜测是列表上的样式写的有问题,可以查一下 flex-direction 和相关属性。




登录后回复