文本框 Input

基本用法

文本框 Input - 图1

  1. <template lang="html">
  2. <div>
  3. <div class="demo-hidden">
  4. <za-panel>
  5. <za-panel-header title="普通"></za-panel-header>
  6. <za-panel-body>
  7. <za-cell title='单行文本'>
  8. <za-input ref='inputFirst' v-model='v1' type="text" placeholder="type is text" @change='handleChange'></za-input>
  9. </za-cell>
  10. <za-cell title='多行文本'>
  11. <za-input v-model='v2' type="textarea" placeholder="type is textarea" @change='handleChange2'></za-input>
  12. </za-cell>
  13. <za-cell>
  14. <a @click='focus'>click to focus the first input</a>
  15. </za-cell>
  16. </za-panel-body>
  17. </za-panel>
  18. <za-panel>
  19. <za-panel-header title="输入类型"/>
  20. <za-panel-body>
  21. <za-cell title='数字'>
  22. <za-input-number v-model='v5' type="number" @change='handleChange'></za-input-number>
  23. </za-cell>
  24. <za-cell title='金额'>
  25. <za-input-number v-model='v6' type="price" @change='handleChange'></za-input-number>
  26. </za-cell>
  27. <za-cell title='证件'>
  28. <za-input-number v-model='v7' type="idcard" @change='handleChange'></za-input-number>
  29. </za-cell>
  30. </za-panel-body>
  31. </za-panel>
  32. <za-panel>
  33. <za-panel-header title="高度自适应"></za-panel-header>
  34. <za-panel-body>
  35. <za-cell title='多行文本'>
  36. <za-input autosize v-model='v3' type="textarea" placeholder="this is a autosize textarea"></za-input>
  37. </za-cell>
  38. </za-panel-body>
  39. </za-panel>
  40. <za-panel>
  41. <za-panel-header title="无标签栏"></za-panel-header>
  42. <za-panel-body>
  43. <za-cell>
  44. <za-input type="text" placeholder="标题" @change='handleChange3'/>
  45. </za-cell>
  46. <za-cell>
  47. <za-input autosize v-model='v4' type="textarea" rows='4' placeholder="摘要"></za-input>
  48. </za-cell>
  49. </za-panel-body>
  50. </za-panel>
  51. <za-panel>
  52. <za-panel-header title="显示输入字数"></za-panel-header>
  53. <za-panel-body>
  54. <za-cell>
  55. <za-input autosize show-length type="textarea" rows="4" max-length="200" placeholder="摘要" v-model='v5'></za-input>
  56. </za-cell>
  57. </za-panel-body>
  58. </za-panel>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. export default {
  64. data() {
  65. return {
  66. v1:'',
  67. v2:'这是一个textarea',
  68. v3:'',
  69. v4:'',
  70. v5:'',
  71. v6:'',
  72. v7:'327198092039342',
  73. }
  74. },
  75. methods: {
  76. handleChange(v) {
  77. console.log(this.v1, v);
  78. },
  79. handleChange2(v) {
  80. console.log(this.v2, v);
  81. },
  82. handleChange3(v) {
  83. console.log(v);
  84. },
  85. focus() {
  86. this.$refs.inputFirst.focus()
  87. },
  88. },
  89. };
  90. </script>

API

Input Attributes

属性类型默认值可选值/参数说明
prefixClsstringza-input类名前缀
typestringtext显示类型
disabledboolfalse是否禁用
rowsstring, number多行文本时的显示行数
autosizeboolfalse是否高度自适应
showLengthboolfalse是否显示输入字数

Input Events

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