Skip to content

Commit 2b296dd

Browse files
committed
add usernamelink
1 parent d2629a0 commit 2b296dd

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<template>
2+
<div>
3+
<router-link :to="( '/account/' + String(this.userid))" class="color-regular-text text-normal">{{this.username}} </router-link>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import apiurl from './../../apiurl';
9+
10+
export default {
11+
name: 'UserNameLink',
12+
props: {
13+
userid: {
14+
type: Number,
15+
required: true
16+
}
17+
},
18+
data() {
19+
return {
20+
username: new String()
21+
};
22+
},
23+
methods: {
24+
loadusername(id) {
25+
this.$axios
26+
.get(apiurl('/account/' + String(id)))
27+
.then(res => {
28+
this.username = res.data.res.username;
29+
})
30+
.catch(() => {
31+
this.username = id;
32+
});
33+
}
34+
},
35+
mounted() {
36+
console.log(typeof(this.userid));
37+
this.username = this.userid;
38+
this.loadusername(this.userid);
39+
}
40+
};
41+
</script>

0 commit comments

Comments
 (0)