# Input输入框

通过鼠标或键盘输入内容，是最基础的表单域的包装。

## 何时使用

需要用户输入表单域内容时。

### 基本使用

::: demo v-model绑定

```html
<template>
    <ut-input placeholder='用户名' v-model='username'></ut-input>
</template>
```
:::

### 文本域

::: demo 用于多行输入，指定 type 为一个特殊的 textarea。通过设置 autosize 属性可以使得文本域的高度能够根据文本内容自动进行调整，并且 autosize 还可以设定为一个对象，指定最小行数和最大行数。autosize自适应内容高度，只对 type="textarea" 有效，可传入对象，如，{ minRows: 2, maxRows: 6 }
```html
<template>
    <ut-input type='textarea' autosize style='margin-bottom:10px'></ut-input>
    <ut-input type='textarea' :autosize='{ minRows: 2, maxRows: 6 }'></ut-input>
</template>
```
:::

### 复合型输入框

::: demo 通过前置和后置的 slot 可以实现复合型的输入框。

```less
<template>
    <div class="demo-input">
        <ut-input v-model='username'>
            <template slot='addonBefore'>http://</template>
        </ut-input>
       <ut-input v-model='username'>
            <i slot='icon' class='iconfont icon-user-add'>
       </ut-input>
        <ut-input>
            <template slot='addonBefore'>
                <ut-select class='demo-input-select'>
                    <ut-option value='http://'></ut-option>
                    <ut-option value='https://'></ut-option>
                </ut-select>
            </template>
            <template slot='addonAfter'>.com</template>
        </ut-input>

    </div>
</template>
<style lang="less">
    .demo-input {
        .utear-input+.utear-input{
            margin-top: 15px;
        }
        .demo-input-select {
            display: block;
            margin: -10px;
            .utear-input {
                width: 100px;
                input {
                    border: 0;
                    background: transparent;
                    color: #99a9bf;
                }
            }
        }
    }
</style>
```
:::

### 三种大小

::: demo 输入框有三种尺寸：大、默认（中）、小 。通过设置size为large和small设置为大和小尺寸，不设置为默认（中）尺寸。

```less
<template>
    <div class="inline">
        <ut-input size='large' placeholder='Large input'></ut-input>
        <ut-input placeholder='Default input'></ut-input>
        <ut-input size='small' placeholder='Small input'></ut-input>
    </div>
</template>
<style>
    .inline{
        .utear-input{
             display: inline-block;
        }
    }
</style>
```
:::


<style lang="less">
    .demo-input {
        .utear-input+.utear-input{
            margin-top: 15px;
        }
        .demo-input-select {
            display: block;
            margin: -10px;
            .utear-input {
                width: 100px;
                input {
                    border: 0;
                    background: transparent;
                    color: #99a9bf;
                }
            }
        }
    }
    .inline{
        .utear-input{
             display: inline-block;
        }
    }
</style>
<script>
    export default {
        data(){
            return {
                username:''
            }
        }
    }
</script>