Skip to content

Commit

Permalink
deal width and height to image
Browse files Browse the repository at this point in the history
  • Loading branch information
qizhenshuai committed Aug 20, 2018
1 parent 0146648 commit b9fdcfb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/wxParseImg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ export default {
}
}
const imageHeightStyle = mode === 'widthFix' ? '' : `height: ${computeHeight ? computeHeight : imageheight}px;`;
this.newStyleStr = `${imageHeightStyle}; width: ${hasWidth ? hasWidth : imageWidth}px; ${styleStr}; padding: 0 ${+padding}px; margin: 0 auto; display: block;`;
if (hasWidth > 0 && hasWidth < imageWidth) {
this.newStyleStr = `${styleStr}; ${imageHeightStyle}; padding: 0 ${+padding}px; margin: 0 auto; display: block;`;
} else if (hasWidth == 0 || hasWidth >= imageWidth) {
this.newStyleStr = `${styleStr}; ${imageHeightStyle}; width: ${hasWidth ? hasWidth : imageWidth}px; padding: 0 ${+padding}px; margin: 0 auto; display: block;`;
}
},
// 计算视觉优先的图片宽高
wxAutoImageCal(originalWidth, originalHeight) {
Expand Down

0 comments on commit b9fdcfb

Please sign in to comment.