跳转到内容

input

提供可交互的界面,接收用户的输入,默认为单行

不支持

支持通用属性

名称类型默认值必填描述
typebuttoncheckboxradiotext
checked<boolean>false当前组件的 checked 状态,可触发 checked 伪类,type 为 checkbox 时生效
name<string>-input 组件名称
value<string>-input 组件的值
placeholder<string>-提示文本的内容,type 为 text

支持通用样式

名称类型默认值必填描述
color<color>#000文本颜色
caret-color<color>#000光标颜色
font-size<length>43.2px文本尺寸
text-decoration<string>underline文本下划线,目前只支持 underline
placeholder-color<color>#000提示文本的颜色,type 为 text
width<length><percentage>-
height<length><percentage>-

支持通用事件

名称参数描述
change不同 type 参数不同,具体见下方 change 事件参数input 组件的值、状态发生改变时触发,type 为 button 时无 change 事件
focusindex获取光标返回的下标值

| 参数 | text | speak | checkbox | radio | 备注 | | --- | --- | --- | --- | --- | | name | | √ | √ | | | value | √ | √ | √ | | | checked | | √ | | |

名称参数描述
setSpanObject动态设置文字样式,方法的入参不是必填项 目前只支持设置 color 和 text-decoration
focustype 为 text

setSpan 参数说明如下:

属性类型默认值描述
startNumber-指定开始的位置
endNumber-指定结束的位置
styleObject-设置文字样式 ,不设置样式默认组件本身的样式
<template>
<div style="flex-direction:column;">
<input id="input" value="{{value}}" onfocus="focus"></input>
</div>
<div onclick="setSpan">设置文字样式</div>
</template>
<script>
export default {
data:{
value:'input'
},
//组件获取光标后的回调值,在对应的位置插入值
focus(index){
//把输入框的值转为数组
let data = String(this.value).split('')
//在对应的位置插入对应的值
data.splice(index,0,'插入input的值')
//把转换后的值赋值回去给input组件的value
this.value = data.join('');
},
setSpan(){
//设置文字样式
this.$element('input').setSpan({
start:0,
end:10,
style:{
'text-decoration':'underline',
'color':'#000'
}
});
}
}
</script>

修改 checkbox 组件的颜色

<template>
<div style="flex-direction:column;">
<input checked="{{checked}}" color='#a52a2a' type='checkbox'></input>
</div>
</template>
<script>
export default {
data:{
checked:true
}
}
</script>

修改 radio 组件的颜色

<template>
<div style="flex-direction:column;">
<input checked="{{checked}}" color="#399FFF" type="radio"> </input>
</div>
</template>
<script>
export default {
data:{
checked:true
}
}
</script>