Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化 image 组件 #1090

Merged
merged 1 commit into from
Jan 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/core/view/components/image/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@resize="_resize" />
</uni-image>
</template>
<script>
<script>
export default {
name: 'Image',
props: {
Expand Down Expand Up @@ -122,18 +122,18 @@ export default {
},
_fixSize () {
const elWidth = this._getWidth()
if (elWidth) {
let height = elWidth / this.ratio
// fix: 解决 Chrome 浏览器上某些情况下导致 1px 缝隙的问题
if (typeof navigator && navigator.vendor === 'Google Inc.' && height > 10) {
height = Math.round(height / 2) * 2
if (elWidth) {
let height = elWidth / this.ratio
// fix: 解决 Chrome 浏览器上某些情况下导致 1px 缝隙的问题
if (typeof navigator && navigator.vendor === 'Google Inc.' && height > 10) {
height = Math.round(height / 2) * 2
}
this.$el.style.height = height + 'px'
this.sizeFixed = true
}
},
_loadImage () {
this.$refs.content.style.backgroundImage = this.src ? `url(${this.realImagePath})` : 'none'
this.$refs.content.style.backgroundImage = this.src ? `url("${this.realImagePath}")` : 'none'

const _self = this
const img = new Image()
Expand Down