Skip to content

Instantly share code, notes, and snippets.

@Phunky
Created September 9, 2016 11:42
Show Gist options
  • Save Phunky/080260d2a225cf1394e2c86c2f21cd55 to your computer and use it in GitHub Desktop.
Save Phunky/080260d2a225cf1394e2c86c2f21cd55 to your computer and use it in GitHub Desktop.
<template lang="pug">
figure(v-bem, :modifiers="modifiers", :style="{width:width + 'px', height:height + 'px'}")
img( :src="url", :alt='alt', :style="{width:width + 'px', height:height + 'px'}")
</template>
<script>
export default {
props: {
src: {
type: String,
default: ''
},
alt: {
type: String,
default: ''
},
width: {
type: Number,
default: 300
},
height: {
type: Number,
default: 225
}
},
computed: {
url () {
return this.src ? this.src : 'http://placehold.it/' + this.width + 'x' + this.height + '/'
},
getHeight () {
return this.height + 'px'
}
}
}
</script>
<style lang="stylus" scoped>
@import '../../styl/common'
+o(image)
display: block
position: relative
img
display: block
height: auto
width: 100%
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment