文本框 Input

普通

  1. <za-cell title="单行文本">
  2. <za-input ref="inputFirst" v-model="v1" type="text" placeholder="type is text" @change="handleChange" :clearable="true"></za-input>
  3. </za-cell>
  4. <za-cell title="多行文本">
  5. <za-input v-model="v2" type="textarea" placeholder="type is textarea" @change="handleChange2" :clearable="true"></za-input>
  6. </za-cell>
  7. <za-cell>
  8. <za-button size="xs" theme="primary" @click="focus">click to focus the first input</za-button>
  9. </za-cell>

输入类型

  1. <za-cell title="数字">
  2. <za-input-number v-model="v5" type="number" placeholder="type is number" @change="handleChange"></za-input-number>
  3. </za-cell>
  4. <za-cell title="金额">
  5. <za-input-number v-model="v6" type="price" placeholder="type is price" @change="handleChange"></za-input-number>
  6. </za-cell>
  7. <za-cell title="证件号">
  8. <za-input-number v-model="v7" placeholder="type is idcard" type="idcard" @change="handleChange"></za-input-number>
  9. </za-cell>

只读 / 禁用状态

  1. <za-cell title="单行文本">
  2. <za-input v-model="v8" type="text" readonly></za-input>
  3. </za-cell>
  4. <za-cell title="单行文本">
  5. <za-input v-model="v9" disabled></za-input>
  6. </za-cell>
  7. <za-cell title="多行文本">
  8. <za-input v-model="v8" rows="4" type="textarea" readonly></za-input>
  9. </za-cell>
  10. <za-cell title="多行文本">
  11. <za-input v-model="v9" rows="4" type="textarea" disabled></za-input>
  12. </za-cell>
  13. <za-cell title="数字类型">
  14. <za-input-number v-model="v5" disabled type="number" placeholder="type is number" @change="handleChange"></za-input-number>
  15. </za-cell>

高度自适应

  1. <za-cell title="多行文本">
  2. <za-input auto-height v-model="v3" type="textarea" placeholder="this is a auto-height textarea"></za-input>
  3. </za-cell>

无标签栏

  1. <za-cell>
  2. <za-input type="text" placeholder="标题" @change="handleChange3">
  3. </za-input></za-cell>
  4. <za-cell>
  5. <za-input auto-height v-model="v4" type="textarea" rows="4" placeholder="摘要"></za-input>
  6. </za-cell>

显示输入字数

  1. <za-cell>
  2. <za-input auto-height show-length type="textarea" rows="4" max-length="200" placeholder="摘要" v-model="v5"></za-input>
  3. </za-cell>

Vue Script

  1. <script name="vue">
  2. export default {
  3. data() {
  4. return {
  5. v1:'',
  6. v2:'这是一个textarea',
  7. v3:'',
  8. v4:'',
  9. v5:'',
  10. v6:'',
  11. v7:'',
  12. v8:'我是只读状态',
  13. v9:'我是禁用状态'
  14. }
  15. },
  16. methods: {
  17. handleChange(v) {
  18. console.log(this.v1, v);
  19. },
  20. handleChange2(v) {
  21. console.log(this.v2, v);
  22. },
  23. handleChange3(v) {
  24. console.log(v);
  25. },
  26. focus() {
  27. this.$refs.inputFirst.focus()
  28. },
  29. },
  30. };
  31. </script>

API

Input Attributes

属性类型默认值可选值/参数说明
typestringtext显示类型
v-modelstring绑定值
disabledbooleanfalse是否禁用
readonlybooleanfalse是否只读
rowsstring, number多行文本时的显示行数
auto-heightbooleanfalse是否高度自适应
show-lengthbooleanfalse是否显示输入字数

Input Events

事件名称说明回调参数
change当绑定值变化时触发的事件最新的值

Input 文本框 - 图1