fet : routing home page articles author name click -> Profile page

This commit is contained in:
kms
2022-11-27 15:47:51 +09:00
parent ea3ab8bc3a
commit 534f62c4e8
2 changed files with 20 additions and 16 deletions

View File

@@ -4,7 +4,9 @@
<div class="article-meta">
<a href="profile.html"><img :src="art.author.image"/></a>
<div class="info">
<a href="" class="author">{{art.author.username}}</a>
<a class="author"
href="javascript:void(0)"
@click="showProfile(art.author.username)">{{art.author.username}}</a>
<span class="date">{{ art.createdAt }}</span>
</div>
<button class="btn btn-outline-primary btn-sm pull-xs-right">
@@ -23,6 +25,7 @@
<script lang="ts">
import {onMounted, reactive, ref, defineComponent} from "vue";
import axios from "axios";
import router from "@/router";
export default defineComponent({
name: "ArticleListGlobal",
@@ -36,20 +39,27 @@ export default defineComponent({
const articles = reactive({
article: {
art: {
slug: String,
title: String,
description: String,
favoritesCount: Number,
createdAt: String,
slug: "",
title: "",
description: "",
favoritesCount: 0,
createdAt: "",
author: {
username: String,
image: String
username: "",
image: ""
}
}
},
articlesCount: "",
})
const showProfile = (username: string) => {
router.push({
name: 'Profile',
params: {username: username}
})
}
onMounted(() => {
axios.get(url + "/api/articles", )
.then(response => {
@@ -62,7 +72,7 @@ export default defineComponent({
}
});
})
return { articles }
return { articles, showProfile }
}
})
</script>

View File

@@ -59,11 +59,6 @@ export default {
password: "",
})
const allHideError = () => {
emailDuplicate.value = false;
usernameDuplicate.value = false;
}
const showEmailUsernameError = () => {
emailDuplicate.value = true;
usernameDuplicate.value = true
@@ -84,7 +79,6 @@ export default {
user
})
.then(response => {
allHideError();
store.dispatch("LOGIN",response.data.user);
router.push({name:"Home"});
})
@@ -100,7 +94,7 @@ export default {
})
}
return { user, emailDuplicate, usernameDuplicate, signup, showEmailUsernameError,showEmailError, showUsernameError, allHideError }
return { user, emailDuplicate, usernameDuplicate, signup, showEmailUsernameError,showEmailError, showUsernameError }
},
}