Commit f002c51683ffce971c66a795e686b81de6657d23
Committed by
小小鲁班
1 parent
69d21501
图片组件新增填充方式属性
Showing
1 changed file
with
19 additions
and
2 deletions
front-end/h5/src/components/plugins/lbp-picture.js
| ... | ... | @@ -4,10 +4,27 @@ import placeholderImg from './lbp-picture-placeholder.png' // issue #34 |
| 4 | 4 | export default { |
| 5 | 5 | name: 'lbp-picture', |
| 6 | 6 | render () { |
| 7 | - return <img src={this.imgSrc || placeholderImg} alt="" srcset="" width="100%" /> | |
| 7 | + return <img src={this.imgSrc || placeholderImg} style={{ objectFit: this.fillType }} alt="" srcset="" width="100%" /> | |
| 8 | 8 | }, |
| 9 | 9 | props: { |
| 10 | - imgSrc: PropTypes.image() | |
| 10 | + imgSrc: PropTypes.image(), | |
| 11 | + fillType: { | |
| 12 | + type: String, | |
| 13 | + default: 'contain', | |
| 14 | + editor: { | |
| 15 | + type: 'a-select', | |
| 16 | + label: '填充方式', | |
| 17 | + props: { | |
| 18 | + options: [ | |
| 19 | + { label: 'contain 短边缩放', value: 'contain' }, | |
| 20 | + { label: 'cover 长边缩放', value: 'cover' }, | |
| 21 | + { label: 'fill 拉伸', value: 'fill' }, | |
| 22 | + { label: 'none 原始', value: 'none' }, | |
| 23 | + { label: 'scale-down 弹性缩放', value: 'scale-down' } | |
| 24 | + ] | |
| 25 | + } | |
| 26 | + } | |
| 27 | + } | |
| 11 | 28 | }, |
| 12 | 29 | data: () => ({ |
| 13 | 30 | placeholderImg | ... | ... |