input表单:
基础库 1.0.0 开始支持,低版本需做兼容处理。
输入框。该组件是原生组件,使用时请注意相关限制
属性类型默认值必填说明最低版本
valuestring是输入框的初始内容1.0.0
typestringtext否input 的类型1.0.0
合法值说明最低版本
text文本输入键盘
number数字输入键盘
idcard身份证输入键盘
digit带小数点的数字键盘
safe-password密码安全输入键盘 指引2.18.0
nickname昵称输入键盘2.21.2
passwordbooleanfalse否是否是密码类型1.0.0
placeholderstring是输入框为空时占位符1.0.0
placeholder-stylestring是指定 placeholder 的样式1.0.0
placeholder-classstringinput-placeholder否指定 placeholder 的样式类1.0.0
disabledbooleanfalse否是否禁用1.0.0
maxlengthnumber140否最大输入长度,设置为 -1 的时候不限制最大长度1.0.0
cursor-spacingnumber0否指定光标与键盘的距离,取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离1.0.0
auto-focusbooleanfalse否(即将废弃,请直接使用 focus )自动聚焦,拉起键盘1.0.0
focusbooleanfalse否获取焦点1.0.0
confirm-typestringdone否设置键盘右下角按钮的文字,仅在type='text'时生效1.1.0
合法值说明
send右下角按钮为“发送”
search右下角按钮为“搜索”
next右下角按钮为“下一个”
go右下角按钮为“前往”
done右下角按钮为“完成”
<viewclass="page-body">
<viewclass="page-section">
<viewclass="weui-cells__title">可以自动聚焦的input</view>
<viewclass="weui-cells weui-cells_after-title">
<viewclass="weui-cell weui-cell_input">
<inputclass="weui-input"auto-focusplaceholder="将会获取焦点"/></view></view></view>
wx.setStorageSync(string key, any data):
将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
wx.setStorage(Object object):
将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
wx.setStorage({key:"key",data:"value"})
wx.setStorage({key:"key",data:"value",encrypt:true,// 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 truesuccess(){wx.getStorage({key:"key",
encrypt:true,// 若开启加密存储,setStorage 和 getStorage 需要同时声明 encrypt 的值为 truesuccess(res){console.log(res.data)}})}})