element-plus/docs/examples/avatar/fit.vue
sea ade87f6729
docs(examples): standardize unified code format and fix some type (#16370)
* docs: standardize unified example code format and fix some example type

* docs:  update some example type

* Update docs/examples/descriptions/sizes.vue

Co-authored-by: kooriookami <38392315+kooriookami@users.noreply.github.com>

* docs: update example-page-header

* docs: update example-page-header

---------

Co-authored-by: kooriookami <38392315+kooriookami@users.noreply.github.com>
2024-04-15 16:29:21 +08:00

46 lines
922 B
Vue

<template>
<div class="demo-fit">
<div v-for="fit in fits" :key="fit" class="block">
<span class="title">{{ fit }}</span>
<el-avatar shape="square" :size="100" :fit="fit" :src="url" />
</div>
</div>
</template>
<script lang="ts" setup>
import { reactive, toRefs } from 'vue'
import type { ObjectFitProperty } from 'csstype'
const state = reactive({
fits: [
'fill',
'contain',
'cover',
'none',
'scale-down',
] as ObjectFitProperty[],
url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
})
const { fits, url } = toRefs(state)
</script>
<style scoped>
.demo-fit {
display: flex;
text-align: center;
justify-content: space-between;
}
.demo-fit .block {
flex: 1;
display: flex;
flex-direction: column;
flex-grow: 0;
}
.demo-fit .title {
margin-bottom: 10px;
font-size: 14px;
color: var(--el-text-color-secondary);
}
</style>