textarea


多行输入框

示例

  1. <template>
  2. <view class="page-demo">
  3. <text class="title-text" >focus聚焦</text>
  4. <view class="input-wrap">
  5. <textarea placeholder="focus聚焦" focus="{{isfocus}}" c-bind:blur="bindblurevent"></textarea>
  6. </view>
  7. <text class="title-text"><text>数据绑定,value:{{inputValue}}</text></text>
  8. <view class="input-wrap">
  9. <textarea placeholder="数据绑定" value="" c-bind:input="inputEvent"></textarea>
  10. </view>
  11. <text class="title-text"><text>监听input事件,当前事件:{{eventName}}</text></text>
  12. <view class="input-wrap">
  13. <textarea placeholder="监听textarea事件" c-bind:input="testEvent" c-bind:blur="testEvent" c-bind:focus="testEvent" c-bind:confirm="testEvent"></textarea>
  14. </view>
  15. <text class="title-text">placeholderColor web端不支持</text>
  16. <view class="input-wrap">
  17. <textarea placeholder="placeholderColor web端不支持" placer-holder-color="#ff0000;" ></textarea>
  18. </view>
  19. <text class="title-text">自定义样式</text>
  20. <view class="end-item">
  21. <textarea placeholder="自定义样式" cstyle="color: #00ff00; border: 1px solid #00f;" ></textarea>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. class Texrarea {
  27. data = {
  28. isfocus: false,
  29. inputValue: '',
  30. eventName: '触发的事件名称'
  31. }
  32. computed = {}
  33. watch = {}
  34. methods = {
  35. inputEvent(e) {
  36. this.inputValue = e.detail.value;
  37. },
  38. testEvent(e) {
  39. this.eventName = e.type
  40. },
  41. bindblurevent() {
  42. console.log('blur')
  43. this.isfocus = false;
  44. }
  45. }
  46. mounted(res) {
  47. setTimeout(() => {
  48. this.isfocus = true;
  49. }, 300);
  50. }
  51. };
  52. export default new Texrarea();
  53. </script>
  54. <style scoped>
  55. .page-demo {
  56. background: #FAFAFA;
  57. position: absolute;
  58. top:0;
  59. bottom:0;
  60. left:0;
  61. right:0;
  62. }
  63. .title-text {
  64. color: #999;
  65. margin: 30cpx 20cpx 10cpx;
  66. display: block;
  67. font-size: 28cpx;
  68. }
  69. .end-item {
  70. margin-bottom: 40cpx;
  71. position: relative;
  72. border-top: 1px solid #D9D9D9;
  73. border-bottom: 1px solid #D9D9D9;
  74. }
  75. .input-wrap {
  76. position: relative;
  77. border-top: 1px solid #D9D9D9;
  78. border-bottom: 1px solid #D9D9D9;
  79. }
  80. </style>
  81. <script cml-type="json">
  82. {
  83. "base": {}
  84. }
  85. </script>