demo.vue 1.4 KB

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