max-height.vue 745 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <template>
  2. <el-button @click="add">Add Item</el-button>
  3. <el-button @click="onDelete">Delete Item</el-button>
  4. <el-scrollbar max-height="400px">
  5. <p v-for="item in count" :key="item" class="scrollbar-demo-item">
  6. {{ item }}
  7. </p>
  8. </el-scrollbar>
  9. </template>
  10. <script lang="ts" setup>
  11. import { ref } from 'vue'
  12. const count = ref(3)
  13. const add = () => {
  14. count.value++
  15. }
  16. const onDelete = () => {
  17. if (count.value > 0) {
  18. count.value--
  19. }
  20. }
  21. </script>
  22. <style scoped>
  23. .scrollbar-demo-item {
  24. display: flex;
  25. align-items: center;
  26. justify-content: center;
  27. height: 50px;
  28. margin: 10px;
  29. text-align: center;
  30. border-radius: 4px;
  31. background: var(--el-color-primary-light-9);
  32. color: var(--el-color-primary);
  33. }
  34. </style>