博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
小程序中如何制作瀑布流效果
阅读量:6998 次
发布时间:2019-06-27

本文共 2112 字,大约阅读时间需要 7 分钟。

这个是我做的瀑布流的效果,如果想要这样效果的可参考下。

 

首先在微信开发者工具的页面中写出来这种两列的格式,左边一部分右边一部分,代码如下:

<view class="city_history">

<view class="history_content">

        <scroll-view scroll-y="true"  style="height: {

{ windowHeight }}px; width: {
{ windowWidth }}px;" bindscrolltolower="loadMore" >

          <view class="left">

             <view wx:for="{

{trips}}" wx:for-item="item" wx:key="" >

                <template is="m-history"  wx:if="{

{index%2==0}}" data="{
{ trip : item}}" />            

             </view>      

          </view>

          <view class="right">

            <view wx:for="{

{trips}}" wx:for-item="item" wx:key="">

              <template is="m-history"  wx:if="{

{index%2==1}}" data="{
{ trip : item}}" />

            </view>

          </view>

        </scroll-view>

        </view>

    </view>

 

样式代码如下:

/**index.wxss**/

.city_history{

  margin-top:10px;

  padding-top:5px;

  border-top:1px #dadada solid;

}

.history_content{

  clear:both;

  overflow: hidden;

  width:100%;

}

.history_content .left,.history_content .right{

  width:49%;

}

.history_content .left{

  float:left;

}

.history_content .right{

  float:right;

}

.history_item{

  display: inline-block;

  background:#fff;

  margin-bottom: 20px;

  border-radius: 10px;

  width:100%;

}

.item-img{

  width:100%;

  border-radius: 10px 10px 0 0 ;

}

.item-title{

  padding:10px;

  font-size: 14px;

  font-family: 'PingFang SC-Medium';

  color: #1e1e1e;

}

.item-ava{

  width: 35px;

  height: 35px;

  border-radius: 100%;

  float:left;

  margin-right:10px;

}

.history_auth_name{

  padding:0 0 10px 10px;

}

.name-title{

  font-size:12px;

  font-family: 'PingFang SC-Medium';

  color: #1e1e1e;

  display: block;

}

外部的components代码如下:

<!--conponents/history.wxml-->

<text>conponents/history.wxml</text>

<template name="m-history" class="history_item">

  <view class="history_item">

    <image class="item-img" src="{

{trip.cover_image}}" mode="widthFix"></image>

    <view class="item-title-box">

      <view url="url" class="item-title">{

{trip.name}}</view> 

    </view>

    <view class="history_auth_name">

      <image class="item-ava" src="{

{trip.cover_image_default}}"></image>    

      <text class="name-title">{

{trip.desc}}</text>

      <text class="name-title">2018-12-1</text>

    </view>

  </view>

</template>

以上就是部分瀑布流的代码 整个具体的文件可以上我的github下载https://github.com/chengwenxia1100/pbl

转载于:https://www.cnblogs.com/chengwx/p/10179075.html

你可能感兴趣的文章
eclipse里面的常用快捷键
查看>>
Redis系列九:redis集群高可用
查看>>
Expdp/impdp常用方法总结
查看>>
021PHP基础知识——代码重用
查看>>
类方法
查看>>
html5 实现手机摇一摇功能(A)
查看>>
logrotate关于日志轮询和分割
查看>>
iOS控件之UIScrollView
查看>>
Calculator
查看>>
解决Mac OS编译安装时出现 cannot find openssl's <evp.h> 错误的问题
查看>>
Java全栈程序员之03:Ubuntu下安装idea
查看>>
linux 基础学习常见问题
查看>>
【Telerik控件学习】-建立自己的图形编辑工具(Diagram)
查看>>
sync 修饰符在Vue中如何使用
查看>>
HDU 4850 Wow! Such String! 【欧拉回路】【一顿乱构造】
查看>>
Multicast
查看>>
[转]Vim 复制粘帖格式错乱问题的解决办法
查看>>
[Android学习笔记]Android Library Project的使用
查看>>
设计MP3搜索引擎
查看>>
Android入门开发时注意的两个问题
查看>>