小程序笔记3常用组件讲解及其使用(含代码,持续更新)

 

 

<!--pages/list/list.wxml-->
<!-- <text>pages/list/list.wxml</text> -->
<view class="container1">
<view>A</view>
<view>B</view>
<view>C</view>
</view>
/* pages/list/list.wxss */
.container1 view{
    width: 100px;
    height: 100px;
    text-align: center;
    line-height: 100px;
}
.container1 view:nth-child(1){
background-color: lightgreen;
}
.container1 view:nth-child(2){
    background-color: lightskyblue;
}
.container1 view:nth-child(3){
    background-color: lightpink;
}

.container1{
    display: flex ;/* //使abc横向 */
    justify-content:space-around ;/*分散对齐*/
}

 

<!-- scroll-x 属性 允许横向滚动 -->
<!-- scroll-y 属性 允许纵向滚动 -->
<!-- 注意:使用竖向滚动时,必须给scroll-view 一个固定高度 -->
<scroll-view class="container2" scroll-y="true" scroll-x="true" >
<view>D</view>
<view>E</view>
<view>F</view>
</scroll-view>
/* --------- */


.container2{
    border: 1px solid red;
    width: 100px;
    /* 给scroll-view固定高度 一定要比原本的大 */
    height: 120px;
}
.container2 view{
    margin-top: 10px;
    width: 100px;
    height: 100px;
    text-align: center;
    line-height: 100px;
}

.container2 view:nth-child(1){
    background-color: lightgreen;
    }
    .container2 view:nth-child(2){
        background-color: lightskyblue;
    }
    .container2 view:nth-child(3){
        background-color: lightpink;
    }


<!-- 轮播图结构 -->
<!-- indicator-dots属性:显示面板指示点 -->
<swiper class="swiper-container">
<!-- 第一张轮播图 -->
<swiper-item  >
    <view class="item">G</view>
</swiper-item>
<!-- 第二张轮播图 -->
<swiper-item>
    <view class="item">H</view>
</swiper-item>
<!-- 第三张轮播图 -->
<swiper-item>
    <view class="item">I</view>
</swiper-item>
</swiper>

/* ------ */
.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: lightpink;
}

<!-- indicator-dots="true" :是否显示面板指示点
indicator-color="white":指示点的颜色
 indicator-active-color="gray":当前选中的指示点颜色
autoplay="true" 是否自动切换
interval="3000" 自动切换时间间隔
circular="true" 是否采用衔接滑动-->
<swiper class="swiper-container" indicator-dots="true" indicator-color="white" indicator-active-color="gray"
autoplay="true" interval="3000" circular="true">

 


<!-- 常用的基础内容组件text和rich-text的用法 -->
<view>
手机号支持长安选中效果 长按复制
<!-- <text selectable="true">110111011101</text> 旧版-->
<text user-select="ture">110111011101444</text>

</view>

 

<!-- 常用的基础内容组件rich-text的用法 -->
<rich-text nodes="<h1 style='color:red;'>标题</h1>"></rich-text>

 

 

<view>----------通过type指定按钮类型--------</view>
<button>普通按钮</button>
<button type="primary">主色调按钮</button>
<button type="warn">主色调按钮</button>
<!-- <button type="default">主色调按钮</button> -->
<view>----------size"mini"小尺寸按钮--------</view>
<button size="mini">普通按钮</button>
<button type="primary" size="mini">主色调按钮</button>
<button type="warn" size="mini">主色调按钮</button>
<!-- <button type="default" size="mini">主色调按钮</button> -->
<view>----------plan镂空按钮--------</view>
<button size="mini" plain="true">普通按钮</button>
<button type="primary" size="mini" plain="true">主色调按钮</button>
<button type="warn" size="mini" plain="true">主色调按钮</button>

 

<!-- 图片组件 -->
<image></image>
<!-- 缩放模式 宽度不变,高度自动变化,保持原图高比不变 -->
<image src="/images/2.jpg" mode="widthFix"></image>
<!-- 缩放模式 高度不变,宽度自动变化,保持原图高比不变 -->
<image src="/images/2.jpg" mode="heightFix"></image>

<!--pages/list/list.wxml-->
<!-- <text>pages/list/list.wxml</text> -->
<view class="container1">
<view>A</view>
<view>B</view>
<view>C</view>
</view>

<!-- scroll-x 属性 允许横向滚动 -->
<!-- scroll-y 属性 允许纵向滚动 -->
<!-- 注意:使用竖向滚动时,必须给scroll-view 一个固定高度 -->
<scroll-view class="container2" scroll-y="true" scroll-x="true" >
<view>D</view>
<view>E</view>
<view>F</view>
</scroll-view>

<!-- 轮播图结构 -->
<!-- indicator-dots属性:显示面板指示点 -->
<!-- indicator-dots="true" :是否显示面板指示点
indicator-color="white":指示点的颜色
 indicator-active-color="gray":当前选中的指示点颜色
autoplay="true" 是否自动切换
interval="3000" 自动切换时间间隔
circular="true" 是否采用衔接滑动-->
<swiper class="swiper-container" indicator-dots="true" indicator-color="white" indicator-active-color="gray"
autoplay="true" interval="3000" circular="true">
<!-- 第一张轮播图 -->
<swiper-item  >
    <view class="item">G</view>
</swiper-item>
<!-- 第二张轮播图 -->
<swiper-item>
    <view class="item">H</view>
</swiper-item>
<!-- 第三张轮播图 -->
<swiper-item>
    <view class="item">I</view>
</swiper-item>
</swiper>

<!-- 常用的基础内容组件text和rich-text的用法 -->
<view>
手机号支持长安选中效果 长按复制
<!-- <text selectable="true">110111011101</text> 旧版-->
<text user-select="ture">110111011101444</text>
</view>

<!-- 常用的基础内容组件rich-text的用法 -->
<rich-text nodes="<h1 style='color:red;'>标题</h1>"></rich-text>

<view>----------通过type指定按钮类型--------</view>
<button>普通按钮</button>
<button type="primary">主色调按钮</button>
<button type="warn">主色调按钮</button>
<!-- <button type="default">主色调按钮</button> -->
<view>----------size"mini"小尺寸按钮--------</view>
<button size="mini">普通按钮</button>
<button type="primary" size="mini">主色调按钮</button>
<button type="warn" size="mini">主色调按钮</button>
<!-- <button type="default" size="mini">主色调按钮</button> -->
<view>----------plan镂空按钮--------</view>
<button size="mini" plain="true">普通按钮</button>
<button type="primary" size="mini" plain="true">主色调按钮</button>
<button type="warn" size="mini" plain="true">主色调按钮</button>

<!-- 图片组件 -->
<image></image>
<!-- 缩放模式 宽度不变,高度自动变化,保持原图高比不变 -->
<image src="/images/2.jpg" mode="widthFix"></image>
<!-- 缩放模式 高度不变,宽度自动变化,保持原图高比不变 -->
<image src="/images/2.jpg" mode="heightFix"></image>

/* pages/list/list.wxss */
.container1 view{
    width: 100px;
    height: 100px;
    text-align: center;
    line-height: 100px;
}


.container1 view:nth-child(1){
background-color: lightgreen;
}
.container1 view:nth-child(2){
    background-color: lightskyblue;
}
.container1 view:nth-child(3){
    background-color: lightpink;
}

.container1{
    display: flex ;/* //使abc横向 */
    justify-content:space-around ;/*分散对齐*/
}

/* --------- */


.container2{
    border: 1px solid red;
    width: 100px;
    /* 给scroll-view固定高度 一定要比原本的大 */
    height: 120px;
}
.container2 view{
    margin-top: 10px;
    width: 100px;
    height: 100px;
    text-align: center;
    line-height: 100px;
}

.container2 view:nth-child(1){
    background-color: lightgreen;
    }
    .container2 view:nth-child(2){
        background-color: lightskyblue;
    }
    .container2 view:nth-child(3){
        background-color: lightpink;
    }

/* ------ */
.swiper-container{
    height: 150px;
}
.item{
    height: 100%;
    line-height: 150px;
    text-align: center;
}
swiper-item:nth-child(1) .item{/* .item前面要加空格标识全选*/
    background-color: lightgreen;
}
swiper-item:nth-child(2) .item{
    background-color:lightskyblue;
}
swiper-item:nth-child(3) .item{
    background-color: lightpink;
}

/* 图片组件 */
image{
    border: 1px solid red;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值