-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from FEMessage/dev
- Loading branch information
Showing
9 changed files
with
360 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## 自动裁剪 | ||
如果传入 width 或 height 属性,会默认按照客户端的 devicePixelRatio(默认是 2) 获取合适大小的图片。节省流量的同时,保证图片最佳显示效果 | ||
|
||
```vue | ||
<template> | ||
<div> | ||
<p> 原图 宽:400 高:267 </p> | ||
<v-img :src="src"/> | ||
<p> 按宽度等比缩放 宽:100 高:等比缩放<p/> | ||
<v-img :src="src" width="100"/> | ||
<p> 按高度等比缩放 高:100 宽:等比缩放<p/> | ||
<v-img :src="src" height="100"/> | ||
<p> 固定宽高剪裁,宽高:100,居中裁剪,不拉伸图片 </p> | ||
<v-img :src="src" height="100" width="100"/> | ||
<p> 对背景图片使用自动裁剪 </p> | ||
<div v-img="{src}" style="width:100px;height:100px;background-repeat:no-repeat;background-size: 100% auto"></div> | ||
</div> | ||
</template> | ||
<script> | ||
export default { | ||
data() { | ||
return { | ||
src: 'https://image-demo.oss-cn-hangzhou.aliyuncs.com/example.jpg' | ||
} | ||
} | ||
} | ||
</script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
## 自定义 loading 和 error 时的图案有两种方法 | ||
|
||
### 注册组件时全局设置,适合全局修改 | ||
```javascript | ||
import Vue from 'vue' | ||
import VImg from '@femessage/v-img' | ||
|
||
Vue.ues(VImg, { | ||
placeholder: 'https://deepexi-moby.oss-cn-shenzhen.aliyuncs.com/femessage/bean_eater.svg', | ||
error: 'https://deepexi-moby.oss-cn-shenzhen.aliyuncs.com/femessage/iconmonstr-refresh-6.svg' | ||
}) | ||
``` | ||
|
||
### 使用组件时,单独给组件设置 | ||
自定义图案的使用逻辑: 组件属性设置 > 全局设置 > 默认设置 | ||
|
||
### 修改占位图的大小 | ||
load 时可以用类名 `.on-loading`, error 时可以用类名 `.on-error` 覆盖默认的样式 | ||
|
||
```vue | ||
<template> | ||
<div> | ||
自定义 loading 图案 </br> | ||
<v-img width="375" height="375" placeholder="https://deepexi-moby.oss-cn-shenzhen.aliyuncs.com/femessage/bean_eater.svg"/></br> | ||
自定义 error 的图案 </br> | ||
<v-img src="none" width="375" height="375" error="https://deepexi-moby.oss-cn-shenzhen.aliyuncs.com/femessage/iconmonstr-refresh-6.svg"/> | ||
</div> | ||
</template> | ||
<style> | ||
.v-img.on-loading, .v-img.on-error { | ||
background-size: auto !important; | ||
} | ||
</style> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.