微信小程序组件解读和分析:十、input输入框
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
|
< view class = "content" > type:有效值:text 感觉没什么区别 < input placeholder = "type=text" type = "text" value = "" /> < input placeholder = "type=number" type = "number" value = "" /> < input placeholder = "type=idcard" type = "idcard" value = "" /> < input placeholder = "type=digit" type = "digit" value = "" /> password: < input type = "text" password = "{{false}}" placeholder = "请输入密码" /> < input type = "text" password = "{{true}}" placeholder = "请输入密码" /> placeholder: < input placeholder = "占位符" /> disable: < input placeholder = "disable={{false}}" disabled = '{{false}}' /> < input placeholder = "disable={{true}}" disabled = '{{true}}' /> 最大长度: < input maxlength = "10" placeholder = "maxlength='10'最多长度10字符" /> < input maxlength = "5" placeholder = "maxlength='5'最多长度5字符" /> < input maxlength = "-1" placeholder = "值为-1,则不限制长度" /> </ view > |
01
02
03
04
05
06
07
08
09
10
|
.content{ border:1px black solid; margin: 10px; font-size: 10pt; padding: 5px; } input{ border:1px red solid; margin: 5px; } |

01
02
03
04
05
06
07
08
09
10
11
12
|
< view class = "content" > bindinput="当内容改变" < input bindinput = "bindinput" /> bindfocus:当获取焦点 < input bindfocus = "bindfocus" /> bindblur:当失去焦点触发 < input bindblur = "bindblur" /> 内容: < view style = "color:blue" > {{log}} </ view > </ view > |
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
Page({ data:{ log: '事件触发' }, bindblur: function (e){ var value=e.detail.value; this .setData({ log: "bindblur失去焦点.输入框值=" +value }) }, bindinput: function (e){ var value=e.detail.value; this .setData({ log: "bindinput内容改变.输入框值=" +value }) }, bindfocus: function (e){ var value=e.detail.value; this .setData({ log: "bindfocus获取焦点.输入框值=" +value }) } }) |
01
02
03
04
05
06
07
08
09
10
|
.content{ border:1px black solid; margin: 10px; font-size: 10pt; padding: 5px; } input{ border:1px red solid; margin: 5px; } |
属性
|
描述
|
类型
|
默认值
|
value
|
输入框的初始内容
|
String
|
|
type
|
有效值:text, number, idcard, digit
|
String
|
text
|
password
|
是否是密码类型
|
Boolean
|
false
|
placeholder
|
输入框为空时占位符
|
String
|
|
placeholder-style
|
指定 placeholder 的样式
|
String
|
|
placeholder-class
|
指定 placeholder 的样式类
|
String
|
input-placeholder
|
disabled
|
是否禁用
|
Boolean
|
false
|
maxlength
|
最大输入长度, 设置为-1 的时候不限制最大长度
|
Number
|
140
|
auto-focus
|
自动聚焦,拉起键盘。页面中只能有一个 input 或 textarea标签时, 设置 auto-focus 属性
|
Boolean
|
false
|
focus
|
获取焦点(当前开发工具暂不支持)
|
Boolean
|
false
|
bindinput
|
除了date/time类型外的输入框,当键盘输入时,触发input事件,处理函数可以直接 return 一个字符串,将替换输入框的内容。
|
EventHandle
|
|
bindfocus
|
输入框聚焦时触发event.detail = {value: value}
|
EventHandle
|
|
bindblur
|
输入框失去焦点时触发event.detail = {value: value}
|
EventHandle
|
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
<!--属性:--> <!--value:输入框内容--> < input value = "内容" /> <!--type:有效类型text,number,idcard,digit,小编感觉其他三个和text没有明显区别,不清楚是什么问题,正常number应该只允许输入数字,但结果和text一样--> < input type = "text" /> < input type = "number" /> < input type = "idcard" /> < input type = "digit" /> <!--password:密码格式 boolean需要{{}}表示--> < input password = "{{true}}" /> < input password/> 等同于 < input password = "{{false}}" /> <!--placeholder:占位符,对输入框内容提示--> < input placeholder = "占位符" placeholder-class = "占位符静态样式" placeholder-style = "占位符动态样式,可用{{}}进行动态赋值" /> <!--disabled:控制标签有效,或者失效状态,在失效状态,不能获取该值--> < input disabled = "{{true}}" /> < input disabled/> 等同于 < input disabled = "{{false}}" /> <!--maxlength:内容长度限制,默认140--> < input maxlength = "100" /> < input maxlength/> 等同于 < input maxlength = "140" /> <!--focus:初始化时,获取输入焦点(目前开发工具暂不支持)--> < input focus = "{{true}}" /> < input focus/> 等同于 < input focus = "{{false}}" /> <!--auto-focus:当界面只有一个input,自动获取焦点--> < input auto-focus = "{{true}}" /> < input auto-focus/> 等同于 < input auto-focus = "{{false}}" /> <!--事件:--> <!--bindinput:当内容改动时触发--> < input bindinput = "自己定义函数名" > <!--bindfocus:当获取焦点,可用输入状态时触发--> < input bindfocus = "自己定义函数名" > <!--bindblur:当失去焦点触发--> < input bindblur = "自己定义函数名" > |
微信小程序组件解读和分析:十、input输入框的更多相关文章
- 微信小程序组件解读和分析:六、progress进度条
progress进度条组件说明: 进度条,就是表示事情当前完成到什么地步了,可以让用户视觉上感知事情的执行.progress进度条是微信小程序的组件,和HTML5的进度条progress类似. pro ...
- 微信小程序组件解读和分析:五、text文本
text文本组件说明: text 文本就是微信小程序中显示出来的文本. text文本组件的示例代码运行效果如下: 下面是WXML代码: [XML] 纯文本查看 复制代码 ? 1 2 3 4 <v ...
- 微信小程序组件解读和分析:四、icon图标
icon图标组件说明: icon是一种图标格式,用于系统图标.软件图标等,这种图标扩展名为.icon..ico.常见的软件或windows桌面上的那些图标一般都是ICON格式的.在应用上面很多地方 ...
- 微信小程序组件解读和分析:十四、slider滑动选择器
slider滑动选择器组件说明: 滑动选择器. slider滑动选择器示例代码运行效果如下: 下面是WXML代码: [XML] 纯文本查看 复制代码 ? 01 02 03 04 05 06 07 08 ...
- 微信小程序组件解读和分析:十五、switch 开关选择器
switch 开关选择器组件说明: switch,开关选择器.只能选择或者不选.这种属于表单控件或者查询条件控件. switch 开关选择器示例代码运行效果如下: 下面是WXML代码: [XML] 纯 ...
- 微信小程序组件解读和分析:十二、picker滚动选择器
picker滚动选择器组件说明: picker: 滚动选择器,现支持三种选择器,通过mode属性来区分, 分别是普通选择器(mode = selector),时间选择器(mode = time),日期 ...
- 微信小程序组件解读和分析:八、checkbox复选项
checkbox复选项组件说明: checkbox是小程序表单组件中的一个组件,作用是在表单中引导用户做出选择. 要使用checkbox组件,还需要在同组中所有的checkbox标签外使用checkb ...
- 微信小程序组件解读和分析:一、view(视图容器 )
view组件说明: 视图容器 跟HTML代码中的DIV一样,可以包裹其他的组件,也可以被包裹在其他的组件内部.用起来比较自由随意,没有固定的结构. view组件的用法: 示例项目的wxml ...
- 微信小程序组件解读和分析:十三、radio单选项目
radio单选项目组件说明: radio:单选项目. radio-group: 单项选择器,内部由多个<radio/>组成. radio单选项目示例代码运行效果如下: 下面是WXML代码: ...
随机推荐
- [IT学习]Learn Python the Hard Way (Using Python 3)笨办法学Python3版本
黑客余弦先生在知道创宇的知道创宇研发技能表v3.1中提到了入门Python的一本好书<Learn Python the Hard Way(英文版链接)>.其中的代码全部是2.7版本. 如果 ...
- 2015/12/29 eclipse应用 输出三角形
public class Myfirst { public static void main(String[] args) { System.out.println("hello world ...
- struts2 Action获取表单数据
1.通过属性驱动式 1.首先设置 表单中的数据的name值 如:<input type="text" name="username" value=&quo ...
- 20170212-备份ABAP程序
把生产机上所有后续开发的CBO程序都备份下来.以备急用! 用过2种方法:1.写BDC程序,模拟 TCODE:SE38 -->Program --> Utilities(M)-->Mo ...
- IDEA及时更新js代码
需要在Tomcat的设置中为: on ‘update‘ action:当用户主动执行更新的时候更新 快捷键:Ctrl + F9 on frame deactication:在编辑窗口失去焦点的时候更新 ...
- lucene segment会包含所有的索引文件,如tim tip等,可以认为是mini的独立索引
A Lucene index segment can be viewed as a "mini" index or a shard. Each segment is a colle ...
- xcode 8.1 (8B62)真机调试配置
1.点击菜单栏中的Xcode->Preferences->Accounts,如图: 点击上图左下角中的“+”号,登陆一个Apple id(前提已经有了一个apple id账号), 2.然后 ...
- SPOJ:Labyrinth(最大直线)
The northern part of the Pyramid contains a very large and complicated labyrinth. The labyrinth is d ...
- python3中urllib的基本使用
urllib 在python3中,urllib和urllib2进行了合并,现在只有一个urllib模块,urllib和urllib2的中的内容整合进了urllib.request,urlparse整合 ...
- 洛谷P3778 [APIO2017]商旅——01分数规划
题目:https://www.luogu.org/problemnew/show/P3778 转化有点技巧: 其实直接关注比率的上下两项,也就是盈利和时间: 通过暴枚和 floyd 可以处理出两两点间 ...