微信小程序01-布局

布局

Flex弹性布局

  1. .container{
    display: flex;
    flex-direction: row;水平排布
    flex-direction: row-reverse;水平取倒叙排布
    flex-direction: column;垂直排布
    flex-direction: column-reverse;垂直倒序排布
    
    
    .container{
    display: flex;
    flex-direction: row;
    height: 400px;
    background-color: pink;
    justify-content: flex-start;左对齐
    justify-content: flex-end;左对齐
    justify-content: center;剧中
    justify-content: center;平均分布
    justify-content: space-around;等距分布
    主轴、交叉轴
    .container{
    display: flex;
    flex-direction: row;
    height: 400px;
    background-color: pink;
    justify-content: center;即在水平剧中,主轴上得对齐
    align-items: center;又在垂直剧中,交叉轴上得对齐
    }
    
    
    .container{
    display: flex;
    flex-direction: column;
    height: 400px;
    background-color: pink;
    justify-content: space-start;
    justify-content:space-evenly;平分间距
    align-items: center;
    align-items: baseline;view里文字下标对齐
    flex-wrap: nowrap;默认不换行
    flex-wrap: wrap;换行,当你得元素宽度大于屏幕宽度,默认不换行,换行后得下一个元素默认剧中
    align-content:center换行后的排列方式
    

     

  2.  

 

条件渲染

if渲染
<view wx:if="{{length > 5}}"> 1 </view>
<view wx:elif="{{length > 2}}"> 2 </view>
<view wx:else> 3 </view>
block渲染
<block wx:if="{{true}}">
  <view> view1 </view>
  <view> view2 </view>
</block>

列表渲染 

<view wx:for="{{array}}">
  {{index}}: {{item.message}}
</view>

 模板

定义模板

定义模板
<template name="msgItem">
</template>
使用模板
<template is="msgItem" data="{{...item}}"/>

点击事件-参数传递

<view class="article-group" wx:for="{{article}}" bindtap="onArticle" data-id="{{item.id}}">
{{item.name}}
</view>

事件冒泡:
bind 会冒泡
catch 不会冒泡

 w'xss细节;

.out-box{
  width: 100%;
  height: 100px;
  border-bottom : 1px #e4e4e4 solid;
  padding: 10px 10px;  边距
  box-sizing: border-box  边距生效
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值