demo.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div class="demo-nopading">
  3. <h2>基础用法</h2>
  4. <nut-textarea
  5. v-model:value="state.val0"
  6. @change="change"
  7. rows="5"
  8. placeholder="高度可拉伸"
  9. :autosize="true"
  10. label="留言:"
  11. />
  12. <h2>显示字数统计</h2>
  13. <nut-textarea
  14. v-model:value="state.val1"
  15. @change="change"
  16. rows="5"
  17. :limitShow="true"
  18. maxLength="20"
  19. type="textarea"
  20. placeholder="设置输入五行"
  21. label="留言:"
  22. />
  23. </div>
  24. </template>
  25. <script lang="ts">
  26. import { reactive } from 'vue';
  27. import { createComponent } from '@/utils/create';
  28. const { createDemo } = createComponent('textarea');
  29. export default createDemo({
  30. setup() {
  31. const state = reactive({
  32. val0: '',
  33. val1: '初始数据'
  34. });
  35. setTimeout(function() {
  36. state.val1 = '异步测试数据,2秒';
  37. }, 2000);
  38. const change = (num: string | number) => {
  39. console.log('change: ', num);
  40. };
  41. const focus = (num: string | number) => {
  42. console.log('focus:', num);
  43. };
  44. const blur = (num: string | number) => {
  45. console.log('blur:', num);
  46. };
  47. const clear = (num: string | number) => {
  48. console.log('clear:', num);
  49. };
  50. return {
  51. state,
  52. change,
  53. blur,
  54. clear,
  55. focus
  56. };
  57. }
  58. });
  59. </script>
  60. <style lang="scss" scoped>
  61. .demo-nopading {
  62. height: 100%;
  63. background: #f7f8fa;
  64. overflow-x: hidden;
  65. overflow-y: auto;
  66. padding: 0;
  67. padding-top: 57px;
  68. h2 {
  69. padding-left: 25px;
  70. margin-top: 25px;
  71. margin-bottom: 10px;
  72. color: #909ca4;
  73. }
  74. }
  75. </style>