Stackedit/src/components/UserName.vue
2018-09-19 09:59:22 +01:00

25 lines
468 B
Vue

<template>
<span class="user-name">{{name}}</span>
</template>
<script>
import userSvc from '../services/userSvc';
import store from '../store';
export default {
props: ['userId'],
computed: {
name() {
const userInfo = store.state.userInfo.itemsById[this.userId];
return userInfo ? userInfo.name : 'Someone';
},
},
watch: {
userId: {
handler: userId => userSvc.getInfo(userId),
immediate: true,
},
},
};
</script>