【微信小程序】滚动 轮播图 文本

简介: 🍒小程序的宿主环境 - 组件1.scroll-view 组件的基本使用2.swiper 和 swiper-item 组件的基本使用3.text 组件的基本使用4.rich-text 组件的基本使用

🍒小程序的宿主环境 - 组件


1.scroll-view 组件的基本使用


实现如图的纵向滚动效果

<scroll-view class="container_2" scroll-y>
 <view>T</view>
<view>S</view>
<view>J</view>
</scroll-view>
.container_2 view{
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
}
.container_2 view:nth-child(1){
background-color: red;
}
.container_2 view:nth-child(2){
  background-color: yellowgreen;
}
.container_2 view:nth-child(3){
  background-color: blue;
}
.container_2{
  display: flex;
  justify-content: space-around
}
.container_2{
  border: 1px solid yellowgreen;
  height: 130px;
  width: 100px;
}

实现如图的横向滚动效果:


<scroll-view class="container_2" scroll-x>
 <view>横           向           滑           动           演           示</view>
</scroll-view>
.container_2 view{
width: 300px;
height: 100px;
text-align: center;
line-height: 100px;
}
.container_2 view:nth-child(1){
background-color: red;
}
.container_2{
  display: flex;
  justify-content: space-around
}
.container_2{
  border: 1px solid yellowgreen;
  height: 100px;
  width: 100px;
}

2.swiper 和 swiper-item 组件的基本使用


实现如图的轮播图效果:

<swiper class="container_3" indicator-dots>
<swiper-item>
<view class="item">1</view>
</swiper-item>
<swiper-item>
  <view class="item">2</view>
</swiper-item>
<swiper-item>
  <view class="item">3</view>
</swiper-item>
<swiper-item>
  <view class="item">4</view>
</swiper-item>
</swiper>
.container_3{
  height: 160px;
}
.item{
  height: 100%;
  line-height: 150px;
  text-align: center;
}
swiper-item:nth-child(1) .item{
  background-color: burlywood;
}
swiper-item:nth-child(2) .item{
  background-color: yellow;
}
swiper-item:nth-child(3) .item{
  background-color: pink;
}
swiper-item:nth-child(4) .item{
  background-color: aqua;
}

.swiper 组件的常用属性


属性


类型


默认值


说明


indicator-dots


boolean false 是否显示面板指示点


indicator-color color rgba(0, 0, 0, .3) 指示点颜色


indicator-active-color color #000000 当前选中的指示点颜色


autoplay boolean false 是否自动切换


interval number 5000 自动切换时间间隔


circular boolean false 是否采用衔接滑动


3.text 组件的基本使用


文本组件


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


通过 text 组件的 selectable 属性,实现长按选中文本内容的效果:



<view>
手机号:
<text selectable>17608777</text>
</view>

4.rich-text 组件的基本使用


富文本组件


支持把 HTML 字符串渲染为 WXML 结构


<rich-text nodes="<h1 style='color:pink;'>一级标题 <h1>"></rich-text>


相关文章
|
10天前
|
小程序 JavaScript
【微信小程序】之轮播图、swiper、swiper-item、banner组件使用
【微信小程序】之轮播图、swiper、swiper-item、banner组件使用
【微信小程序】之轮播图、swiper、swiper-item、banner组件使用
|
1月前
|
存储 小程序 API
【微信小程序】-- uni-app 项目-- 购物车 -- 首页 - 轮播图效果(五十二)
【微信小程序】-- uni-app 项目-- 购物车 -- 首页 - 轮播图效果(五十二)
【微信小程序】-- uni-app 项目-- 购物车 -- 首页 - 轮播图效果(五十二)
|
3月前
|
小程序 JavaScript
小程序自定义弹窗禁止底部内容滚动(滚动穿透问题)
小程序自定义弹窗禁止底部内容滚动(滚动穿透问题)
|
3月前
|
数据安全/隐私保护
常用的表单校验规则——邮箱/QQ/身份证号码/微信/电话/数字字母/整数/文本/密码等
常用的表单校验规则——邮箱/QQ/身份证号码/微信/电话/数字字母/整数/文本/密码等
54 0
|
1月前
|
小程序
微信小程序scroll-view横向滚动和纵向滚动实现(亲测管用)
微信小程序scroll-view横向滚动和纵向滚动实现(亲测管用)
|
1月前
|
小程序 数据可视化 前端开发
微信小程序开发入门教程-文本组件介绍
微信小程序开发入门教程-文本组件介绍
|
2月前
|
小程序
微信小程序——简易复制文本
微信小程序——简易复制文本
|
2月前
|
小程序
微信小程序中复制文本
微信小程序中复制文本
34 0
|
6天前
|
小程序 前端开发 API
微信小程序全栈开发中的异常处理与日志记录
【4月更文挑战第12天】本文探讨了微信小程序全栈开发中的异常处理和日志记录,强调其对确保应用稳定性和用户体验的重要性。异常处理涵盖前端(网络、页面跳转、用户输入、逻辑异常)和后端(数据库、API、业务逻辑)方面;日志记录则关注关键操作和异常情况的追踪。实践中,前端可利用try-catch处理异常,后端借助日志框架记录异常,同时采用集中式日志管理工具提升分析效率。开发者应注意安全性、性能和团队协作,以优化异常处理与日志记录流程。
|
6天前
|
小程序 安全 数据安全/隐私保护
微信小程序全栈开发中的身份认证与授权机制
【4月更文挑战第12天】本文探讨了微信小程序全栈开发中的身份认证与授权机制。身份认证包括手机号验证、微信登录和第三方登录,而授权机制涉及角色权限控制、ACL和OAuth 2.0。实践中,开发者可利用微信登录获取用户信息,集成第三方登录,以及实施角色和ACL进行权限控制。注意点包括安全性、用户体验和合规性,以保障小程序的安全运行和良好体验。通过这些方法,开发者能有效掌握小程序全栈开发技术。

热门文章

最新文章