fit.vue 825 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <template>
  2. <div class="demo-fit">
  3. <div v-for="fit in fits" :key="fit" class="block">
  4. <span class="title">{{ fit }}</span>
  5. <el-avatar shape="square" :size="100" :fit="fit" :src="url" />
  6. </div>
  7. </div>
  8. </template>
  9. <script lang="ts" setup>
  10. import { reactive, toRefs } from 'vue'
  11. const state = reactive({
  12. fits: ['fill', 'contain', 'cover', 'none', 'scale-down'],
  13. url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
  14. })
  15. const { fits, url } = toRefs(state)
  16. </script>
  17. <style scoped>
  18. .demo-fit {
  19. display: flex;
  20. text-align: center;
  21. justify-content: space-between;
  22. }
  23. .demo-fit .block {
  24. flex: 1;
  25. display: flex;
  26. flex-direction: column;
  27. flex-grow: 0;
  28. }
  29. .demo-fit .title {
  30. margin-bottom: 10px;
  31. font-size: 14px;
  32. color: var(--el-text-color-secondary);
  33. }
  34. </style>