mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
feat(Image): add radius prop (#2407)
This commit is contained in:
parent
7821477518
commit
8f6f61e208
@ -1,5 +1,11 @@
|
||||
# Image 图片
|
||||
|
||||
### 介绍
|
||||
|
||||
增强版的 img 标签,提供多种图片填充模式,支持图片懒加载、加载中提示、加载失败提示。
|
||||
|
||||
使用此组件需要升级至 1.0 以上版本。
|
||||
|
||||
### 引入
|
||||
|
||||
在`app.json`或`index.json`中引入组件,详细介绍见[快速上手](#/quickstart#yin-ru-zu-jian)
|
||||
@ -94,18 +100,19 @@
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||
|------|------|------|------|------|
|
||||
| src | 图片链接 | `string` | - | - |
|
||||
| fit | 图片填充模式 | `string` | `fill` | - |
|
||||
| alt | 替代文本 | `string` | - | - |
|
||||
| width | 宽度,默认单位为`px` | `string | number` | - | - |
|
||||
| height | 高度,默认单位为`px` | `string | number` | - | - |
|
||||
| round | 是否显示为圆形 | `boolean` | `false` | - |
|
||||
| lazy-load | 是否懒加载 | `boolean` | `false` | - |
|
||||
| show-error | 是否展示图片加载失败提示 | `boolean` | `true` | - |
|
||||
| show-loading | 是否展示图片加载中提示 | `boolean` | `true` | - |
|
||||
| use-error-slot | 是否使用 error 插槽 | `boolean` | `false` | - |
|
||||
| use-loading-slot | 是否使用 loading 插槽 | `boolean` | `false` | - |
|
||||
| show-menu-by-longpress | 是否开启长按图片显示识别小程序码菜单 | `boolean` | `false` | - |
|
||||
| src | 图片链接 | *string* | - | - |
|
||||
| fit | 图片填充模式 | *string* | *fill* | - |
|
||||
| alt | 替代文本 | *string* | - | - |
|
||||
| width | 宽度,默认单位为`px` | *string \| number* | - | - |
|
||||
| height | 高度,默认单位为`px` | *string \| number* | - | - |
|
||||
| radius | 圆角大小,默认单位为`px` | *string \| number* | `0` | - |
|
||||
| round | 是否显示为圆形 | *boolean* | `false` | - |
|
||||
| lazy-load | 是否懒加载 | *boolean* | `false` | - |
|
||||
| show-error | 是否展示图片加载失败提示 | *boolean* | `true` | - |
|
||||
| show-loading | 是否展示图片加载中提示 | *boolean* | `true` | - |
|
||||
| use-error-slot | 是否使用 error 插槽 | *boolean* | `false` | - |
|
||||
| use-loading-slot | 是否使用 loading 插槽 | *boolean* | `false` | - |
|
||||
| show-menu-by-longpress | 是否开启长按图片显示识别小程序码菜单 | *boolean* | `false` | - |
|
||||
|
||||
### 图片填充模式
|
||||
|
||||
|
@ -18,8 +18,9 @@ VantComponent({
|
||||
props: {
|
||||
src: String,
|
||||
round: Boolean,
|
||||
width: String,
|
||||
height: String,
|
||||
width: null,
|
||||
height: null,
|
||||
radius: null,
|
||||
lazyLoad: Boolean,
|
||||
useErrorSlot: Boolean,
|
||||
useLoadingSlot: Boolean,
|
||||
@ -65,7 +66,7 @@ VantComponent({
|
||||
},
|
||||
|
||||
getStyle() {
|
||||
const { width, height } = this.data;
|
||||
const { width, height, radius } = this.data;
|
||||
let style = '';
|
||||
|
||||
if (isDef(width)) {
|
||||
@ -76,6 +77,11 @@ VantComponent({
|
||||
style += `height: ${addUnit(height)};`;
|
||||
}
|
||||
|
||||
if (isDef(radius)) {
|
||||
style += 'overflow: hidden;';
|
||||
style += `border-radius: ${addUnit(radius)};`;
|
||||
}
|
||||
|
||||
return style;
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user