Stackedit/src/components/UserImage.vue

31 lines
615 B
Vue
Raw Normal View History

2017-10-02 00:34:48 +00:00
<template>
<div class="user-image" :style="{backgroundImage: url}">
2017-10-02 00:34:48 +00:00
</div>
</template>
<script>
2017-11-15 08:12:56 +00:00
import userSvc from '../services/userSvc';
2017-10-02 00:34:48 +00:00
export default {
props: ['userId'],
computed: {
url() {
2018-07-17 19:58:40 +00:00
userSvc.getInfo(this.userId);
2018-06-21 19:16:33 +00:00
const userInfo = this.$store.state.userInfo.itemsById[this.userId];
2017-11-15 08:12:56 +00:00
return userInfo && userInfo.imageUrl && `url('${userInfo.imageUrl}')`;
2017-10-02 00:34:48 +00:00
},
},
};
</script>
<style lang="scss">
.user-image {
width: 100%;
height: 100%;
2017-11-26 20:58:24 +00:00
background-color: #fff;
2017-10-02 00:34:48 +00:00
background-repeat: no-repeat;
background-position: center;
background-size: contain;
}
</style>