微信小程序-常用小程序组件

简介: 微信小程序-常用小程序组件

常用小程序组件


1、组件介绍

文档地址:https://developers.weixin.qq.com/miniprogram/dev/component/

框架为开发者提供了一系列基础组件,开发者可以通过组合这些基础组件进行快速开发。一个组件通常包括开始标签和结束标签,属性用来修饰这个组件,内容在两个标签之间。


2、swiper组件

文档地址:https://developers.weixin.qq.com/miniprogram/dev/component/swiper.html

案例:使用swiper展示轮播图

逻辑层定义数据

data: {
 background: ["https://storage.lynnn.cn/assets/markdown/91147/pictures/2020/11/bce52a5f143cd3e25c6c39c7a0fd7f276ce43bad.png?sign=f4ec5771f7eabd11226fe5f4b7f0f6e8&t=5fa403f2",
            "https://storage.lynnn.cn/assets/markdown/91147/pictures/2020/11/6018ac895dd29437b1d023c121c7539ecf2e9221.jpeg?sign=47da092f8a6a1650df3da3dd3dd40cb3&t=5fa4041d",
            "https://storage.lynnn.cn/assets/markdown/91147/pictures/2020/11/f81d133833b89a18cb1842f449810d16ec5d3c78.jpeg?sign=22eadb72caac161df642aa18b84127a8&t=5fa40431"
        ]
},

图片采用image组件进行展示,其支持对图片进行缩放、裁剪处理。关于image组件的信息,可以访问文档:https://developers.weixin.qq.com/miniprogram/dev/component/image.html


实际在wxml中展示

<view>
  <swiper indicator-dots indicator-color="rgba(52, 155, 252,1)" autoplay>
  <swiper-item wx:for="{{background}}" wx:key="index">
   <image src="{{item}}" style="width: 100%; height: 100%;"></image>
  </swiper-item>
  </swiper>
</view>

在设计图片的时候,一定要和设计人员对接好图片的合适尺寸比例。


3、表单组件

小程序项目中但凡是涉及到表单的地方,都需要使用表单组件。表单组件的作用就是用于组成表单的。

注意点:

  • 这里面表单组件部分的标签继续沿用html的标签,与之前完全同名
  • 组件标签的部分属性也与之前html属性一致,但是更多的是不一致的


文档地址:https://developers.weixin.qq.com/miniprogram/dev/component/button.html

<!-- 表单 -->
  <!-- 移动端登录表单 -->
  <view class="login_form">
    <image src="/assets/icon/home-seleted.png"/>
    <input type="text" placeholder="用户名"/>
    <input type="password" placeholder="密码"/>
    <button type="primary">登录</button>
    <view class="login_button" hover-class="active">
      view登录
    </view>
  </view>


wxss

/* pages/list/list.wxss */
input{
  border-bottom:1px solid gray;
  height: 120rpx;
  width: 600rpx;
}
.login_form{
  width: 750rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
}
button{
  margin-top: 30rpx;
}
image{
  width: 120rpx;
  height: 120rpx;
}
.login_button{
  margin-top: 30rpx;
  background-color: cadetblue;
  color: white;
  width: 430rpx;
  height: 100rpx;
  border-radius: 10rpx;
  text-align: center;
  line-height: 100rpx;
  font-weight: bold;
}
.active{
  /* 透明度 */
  opacity: 0.7;
}


按钮button组件有一个非常实用的属性open-type,后续可以通过该属性赋予按钮高级的功能(微信开放能力),例如:

  • 获取用户信息的时候
  • 唤起其他App的时候
  • 不是任意app都可以唤起,只能唤起来源app
  • 获取用户手机号
<!-- button open-type属性的多种功能 -->
    <button type="default" open-type="chooseAvatar" bindchooseavatar="getAvatar">测试按钮</button>


目录
相关文章
|
2天前
|
小程序 Java API
微信小程序和springboot实现微信支付
微信小程序和springboot实现微信支付
6 0
|
2天前
|
小程序 API
微信小程序-微信支付
微信小程序-微信支付
6 0
|
13天前
|
小程序 开发工具 Android开发
微信小程序开发工具的使用,各个配置文件详解,小程序开发快速入门(二)
微信小程序开发工具的使用,各个配置文件详解,小程序开发快速入门(二)
|
13天前
|
小程序 JavaScript 开发工具
微信小程序开发工具的使用,各个配置文件详解,小程序开发快速入门(一)
微信小程序开发工具的使用,各个配置文件详解,小程序开发快速入门(一)
|
13天前
|
移动开发 小程序 安全
使用阿里云短信+微信短链接跳转微信小程序
此内容是关于使用阿里云短信带传递参数的微信短链接跳转到微信小程序。首先,需要准备微信开发者工具和一个已认证的小程序。接着,开通云开发并配置云开发权限。然后,配置H5静态网页,包括设置云开发权限和处理不同设备的跳转方式。最后,上传云函数并修改其权限,获取微信短信链接,配置短链接参数,并开通阿里云短信服务以进行测试验证。整个过程涉及到了微信开发者工具、云开发、H5页面配置、云函数的创建和部署以及阿里云短信服务的开通和使用等步骤。
38 0
|
23天前
|
小程序 JavaScript Java
基于SpringBoot+Vue+uniapp微信小程序的在线课堂微信小程序的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的在线课堂微信小程序的详细设计和实现
32 3
|
23天前
|
小程序 JavaScript Java
基于SpringBoot+Vue+uniapp微信小程序的微信课堂助手小程序的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的微信课堂助手小程序的详细设计和实现
56 3
|
23天前
|
小程序 JavaScript Java
基于SpringBoot+Vue+uniapp微信小程序的微信点餐小程序的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的微信点餐小程序的详细设计和实现
31 1
|
23天前
|
小程序 JavaScript Java
基于SpringBoot+Vue+uniapp微信小程序的助农扶贫微信小程序的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的助农扶贫微信小程序的详细设计和实现
33 2
|
23天前
|
小程序 JavaScript Java
基于SpringBoot+Vue+uniapp微信小程序的微信阅读网站小程序的详细设计和实现
基于SpringBoot+Vue+uniapp微信小程序的微信阅读网站小程序的详细设计和实现
43 2