微信小程序之表单组件

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>
相关推荐
Emma歌小白2 天前
如何首次运行小程序后端
微信小程序
赣州云智科技的技术铺子2 天前
【一步步开发AI运动APP】十二、自定义扩展新运动项目1
微信小程序·小程序·云开发·智能小程序
2501_915918412 天前
iOS 上架全流程指南 iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传 ipa 与审核实战经验分享
android·ios·小程序·uni-app·cocoa·iphone·webview
00后程序员张2 天前
iOS App 混淆与加固对比 源码混淆与ipa文件混淆的区别、iOS代码保护与应用安全场景最佳实践
android·安全·ios·小程序·uni-app·iphone·webview
破无差3 天前
《赛事报名系统小程序》
小程序·html·uniapp
00后程序员张3 天前
详细解析苹果iOS应用上架到App Store的完整步骤与指南
android·ios·小程序·https·uni-app·iphone·webview
海绵宝宝不喜欢侬3 天前
uniapp-微信小程序分享功能-onShareAppMessage
微信小程序·小程序·uni-app
2501_915106323 天前
Xcode 上传 ipa 全流程详解 App Store 上架流程、uni-app 生成 ipa 文件上传与审核指南
android·macos·ios·小程序·uni-app·iphone·xcode
亮子AI3 天前
【小程序】微信小程序隐私协议
微信小程序·小程序
weixin_177297220693 天前
短剧小程序系统开发:打造个性化娱乐新平台
小程序·娱乐·短剧