Image 图片
在原生图片的基础上做了二次封装,扩展了更多功能。
按需引入方式
如果是完整引入可跳过此步骤
javascript
import Vue from 'vue'
import { Image } from 'element-ui'
import 'element-ui/lib/theme-chalk/base.css'
import 'element-ui/lib/theme-chalk/image.css'
Vue.use(Image)
基础使用
vue
<template>
<div class="block" v-for="fit in fits" :key="fit">
<span class="demonstration">{{ fit }}</span>
<el-image
style="width: 100px; height: 100px"
:src="url"
:fit="fit"
></el-image>
</div>
</template>
<script>
export default {
data() {
return {
fits: ['fill', 'contain', 'cover', 'none', 'scale-down'],
url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'
}
}
}
</script>
fill
FAILED
contain
FAILED
cover
FAILED
none
FAILED
scale-down
FAILED
大图预览
vue
<template>
<div class="demo-image__preview">
<el-image
style="width: 100px; height: 100px"
:src="url"
:preview-src-list="srcList"
>
</el-image>
</div>
</template>
<script>
export default {
data() {
return {
url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
srcList: [
'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
]
}
}
}
</script>
FAILED
Tabs Attributes
参数 | 说明 | 类型 | 默认值 |
---|---|---|---|
src | 图片源 | string | |
fit | 确定图片如何适应容器框 | string | |
preview-src-list | 开启图片预览功能 | array | |
... |
你认为这篇文章怎么样?
- 0
- 0
- 0
- 0
- 0
- 0
Powered by Waline v2.15.8
Preview: