小程序开发4

#微信小程序开发Day4

小程序的宿主环境-组件

5.swiper和swiper-item组件的基本使用
#实现轮播图的效果

<!--轮播图的结构 -->
<swiper class="swiper-container">
    <!--第一张轮播图 -->
  <swiper-item>
    <view class="item">A</view>
  </swiper-item>
    <!--第二张轮播图 -->
  <swiper-item>
    <view class="item">B</view>
  </swiper-item>
    <!--第三张轮播图 -->
  <swiper-item>
    <view class="item">C</view>
  </swiper-item>
  </swiper>
/* pages/scavenger/scavenger.wxss */
/*轮播图的样式*/
.swiper-container{
    height: 150px;
}
.item{
height: 100%;
line-height: 150px;
text-align: center;
}

swiper-item:nth-child(1) .item{
    background-color: lightgreen;
}
swiper-item:nth-child(2) .item{
    background-color: lightskyblue;
}
swiper-item:nth-child(3) .item{
    background-color: lightsalmon;
}
6.swiper组件的常用属性
属性类型默认值说明
indicator-dotsboooleanfalse是否显示面板指示点
indicator-colorcolorrgba(0,0,0,.3)指示点颜色
indicator-active-colorcolor#000000当前选中的指示点的颜色
autoploybooleanfalse是否自动切换
intervalnumber5000自动切换时间间隔
circularbooleanfalse是否采用衔接滑动
7.常用的基础内容组件
  • 1.text

    • 文本组件

    • 类似于HTML中的span标签,是一个行内元素

      8.text组件的基本使用
  • 通过text组建的selectable属性,实现长按选中文本内容的效果

<view>
手机号长按选中的效果
<text selectable>18852181310</text>
</view>
  • rich-text

    • 富文本组件
    • 支持把HTML字符串渲染为WXML结构
    9.rich-text组件的基本使用
  • 通过rich-text组件的**nodes**属性节点,把HTML字符串渲染为对应的UI结构;

    <rich-text nodes="<h1 style='color: red'>标签:Scvenger.兰淇</h1>"></rich-text>
    
10.其他常用组件

1.button

按钮组件
功能比HTML中的button按钮丰富
通过open—type属性可以调用微信提供的各种功能(客服,转发,获取用户授权,获取用户信息等)

2.image

图片组件
image组件的默认宽度约为300px,高度约240px

3.navigator

页面导航组件
类似于HTML中的a链接

10.1—按钮组件

<view>-------通过type指定按钮类型--------</view>
<!-- 按钮组件的基本使用-->
<button>普通按钮</button>
<button type="primary">主色调普通按钮</button>
<button type= "warn">警告普通按钮</button>
<!-- size ="mini"-->
<button type= "warn" size ="mini">警告普通按钮</button>
<!-- plain 镂空按钮-->
<button type="primary" plain>主色调普通按钮</button>

10.2—image组件

<!-- image 图片组件 -->
<image></image>
<image scr="/images/ani.png"></image>

10.3image组件中的mode属性

image组件中的mode属性用来指定图片的剪裁缩放模式,常用mode属性值如下

mode值说明
scaleToFill(默认值)缩放模式,不保持横纵比例缩放图片,使图片的宽高完全拉伸职场填满image元素
aspectFit缩放模式,保持横纵比例缩放图片,使图片的长边能够完全显示出来,也就是说,可以完整地显示出图片来
aspectFill缩放模式,保持横纵比例缩放图片,只保证图片的短边能够完全显示出来,也就是说,图片只在水平或垂直方向上保持完整
widthFix缩放模式,**宽度不变,高度自动变化,**保持原图宽高比不变
heightFix缩放模式,**高度不变,宽度自动变化,**保持原图宽高比不变
<!-- image 图片组件 -->
<image></image>
<image scr="/images/ani.png"></image>
<image scr="/images/ani.png" mode="aspectFit"></image>
<image scr="/images/ani.png" mode="aspectFill"></image>
<image scr="/images/ani.png" mode="widthFix"></image>
<image scr="/images/ani.png" mode="heightFix"></image>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值