微信小程序之表单组件

1、button

常用的属性:
属性 类型 默认值 必填 说明
size string default 否 按钮的大小
合法值 说明 --------- ------
type string default 否 按钮的样式类型
合法值 说明 --------- ----
plain boolean false 否 按钮是否镂空,背景色透明
disabled boolean false 否 是否禁用
loading boolean false 否 名称前是否带 loading 图标

|---|------------------------|---------|--------------|---|----------------------------------------------|---|
| | hover-class | string | button-hover | 否 | 指定按钮按下去的样式类。当 hover-class="none" 时,没有点击态效果 |
| | hover-stop-propagation | boolean | false | 否 | 指定是否阻止本节点的祖先节点出现点击态 | |
| | hover-start-time | number | 20 | 否 | 按住后多久出现点击态,单位毫秒 | |
| | hover-stay-time | number | 70 | 否 | 手指松开后点击态保留时间,单位毫秒 |

代码案例:
XML 复制代码
<button>这是一个按钮</button>
<button size="mini" type="primary" >这是一个按钮</button>
<button size="mini" type="primary" plain >这是一个按钮</button>
<!--disbaled后就无法继续点击了、plain镂空-->
<button size="mini" type="primary" plain disabled>这是一个按钮</button>
<!--loading属性要设置为false的话,必须这样写:放在差值表达式中,要不然不起作用-->
<button type="primary" loading="{{false}}">这是一个按钮</button>

2、input

常用的属性:
属性 类型 默认值 必填 说明
value string 是 输入框的初始内容
type string text 否 input 的类型
合法值 说明 ---------------
password boolean false 否 是否是密码类型 1.0.0
placeholder string 是 输入框为空时占位符 1.0.0
placeholder-style string 是 指定 placeholder 的样式,目前仅支持 color,font-size和font-weight 1.0.0
disabled boolean false 否 是否禁用 1.0.0
maxlength number 140 否 最大输入长度,设置为 -1 的时候不限制最大长度

|--------------|--------|------|---|-----------------------------------|---|---|
| confirm-type | string | done | 否 | 设置键盘右下角按钮的文字,仅在type='text'时生效 | |
| | | 合法值 | 说明 | |--------|-------------| | send | 右下角按钮为"发送" | | search | 右下角按钮为"搜索" | | next | 右下角按钮为"下一个" | | go | 右下角按钮为"前往" | | done | 右下角按钮为"完成" | ||||||

.wxss:

XML 复制代码
.out{
  padding:30rpx;
  border:1px solid #ccc;
  margin:30rpx;
}

.out .inpt{
  background:#eee;
  margin-bottom: 20rpx;
  padding: 20rpx;
}

.wxml:

XML 复制代码
<!--maxlength:最大能输入的字数,文本块类型默认是text,也有数字键盘等等-->
<view class = "out"> 
  <input type = "text" class="inpt"  maxlength="6"/>
  <button type="primary">提交按钮</button>
</view>
<!--value初始值一般和disabled联合使用,不能修改的、只读的初始值-->
<view class = "out"> 
  <input type = "text" class="inpt" value="初始值"/>
  <button type="primary">提交按钮</button>
</view>
<view class = "out"> 
  <input type = "text" class="inpt" placeholder="请输入用户名" />
  <button type="primary">提交按钮</button>
</view>
 
<view class = "out"> 
  <input type = "text" class="inpt" placeholder="请输入密码" password />
  <button type="primary">提交按钮</button>
</view>
相关推荐
andrsted1 天前
练题簿免费刷题小程序:和学习搭子共用一份题库,一起刷题复习
学习·面试·微信小程序·小程序·学习方法·刷题
万岳科技程序员小金1 天前
教育机构如何搭建在线教学平台?网校系统、小程序与APP开发指南
小程序·在线教育系统源码·教育平台搭建·教育app开发·教育软件开发·教育小程序开发
计算机毕设定制辅导-无忧学长1 天前
《基于微信小程序的个人智能刷题助手的设计与实现》
java·spring boot·mysql·微信小程序·uniapp·个人智能刷题助手系统
百慕大三角1 天前
为了在 Linux CI 里跑小程序 E2E,我把微信官方基础库搬进了浏览器:wxa-runner 开源实践
微信小程序·agent·测试
小小王app小程序开发1 天前
淘宝扭蛋机小程序玩法开发分析
小程序
2501_916008891 天前
马甲包过审卡在哪?Ipa Guard 能做的和做不到的
android·小程序·https·uni-app·iphone·webview
Fxkj8881 天前
佛山企业做小程序:模板定制与源码定制怎么选?
人工智能·小程序
青企通2 天前
电商小程序购物车与库存扣减:SKU 模型、合并规则与防超卖实践
小程序·apache
AI源码2 天前
家乡介绍小程序
小程序·notepad++
2501_915921432 天前
iOS应用耗电测试:使用Energy Log、Keymob和Instruments进行性能监控与能源消耗分析
android·ios·小程序·https·uni-app·iphone·webview