微信小程序的宿主环境怎么实现

发布时间:2022-10-10 14:30:24 作者:iii
来源:亿速云 阅读:125

这篇文章主要介绍了微信小程序的宿主环境怎么实现的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇微信小程序的宿主环境怎么实现文章都会有所收获,下面我们一起来看看吧。

小程序的宿主环境 - 组件

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-y 改成 scroll-x

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

微信小程序的宿主环境怎么实现

 <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

booleanfalse是否显示面板指示点
indicator-colorcolorrgba(0, 0, 0, .3)指示点颜色
indicator-active-colorcolor#000000当前选中的指示点颜色
autoplaybooleanfalse是否自动切换
intervalnumber5000自动切换时间间隔
circularbooleanfalse是否采用衔接滑动

3.text 组件的基本使用

文本组件

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

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

微信小程序的宿主环境怎么实现

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

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

富文本组件

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

微信小程序的宿主环境怎么实现

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

关于“微信小程序的宿主环境怎么实现”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“微信小程序的宿主环境怎么实现”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. 微信小程序如何实现滑动
  2. 微信小程序如何实现tabBar

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

微信小程序

上一篇:怎么使用Docker部署openGauss国产数据库

下一篇:怎么利用Spring框架为自己的校园卡充值

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》