From 57ee2f06857fb43e40e8b1c36e4b6bdfd6f9848a Mon Sep 17 00:00:00 2001 From: yma16 <17685043634@163.com> Date: Sat, 16 Jul 2022 16:58:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E8=B6=85=E6=97=B6loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/comment/ArticleComment.vue | 10 ++++++++-- src/components/Login.vue | 7 +++++-- src/components/Register.vue | 5 +++++ src/components/email/Email.vue | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/comment/ArticleComment.vue b/src/comment/ArticleComment.vue index ec29a00..dcb76e3 100644 --- a/src/comment/ArticleComment.vue +++ b/src/comment/ArticleComment.vue @@ -28,6 +28,7 @@ type="primary" style="margin-left: 5px" @click="increment(userId, articleId, articleCommit)" + v-loading="submitLoading" >提交评论 @@ -43,6 +44,7 @@ export default { // props定义则data()无需定义 data() { return { + submitLoading: false, noneMsg: "还没人评论>_<", msg: "评论区", baseurl: "/api/", @@ -58,7 +60,7 @@ export default { watch: { articleId: function (newData) { this.childArticleId = newData; - return newData + return newData; }, }, mounted() { @@ -100,7 +102,7 @@ export default { getComments(articleId) { let that = this; let params = { - articleId: articleId ? articleId : that.articleId, + articleId: articleId || that.articleId, }; axios .post(that.baseurl + "comment/get/", params) @@ -138,6 +140,7 @@ export default { }); return false; } + that.submitLoading = true; const userInfo = JSON.parse(localStorage.getItem("yma16siteUserInfo")); that.userId = userInfo.username; let params = { @@ -148,6 +151,7 @@ export default { axios .post(that.baseurl + "comment/post/", params) .then((res) => { + that.submitLoading = false; that.articleCommit = null; try { let resData = res.data; @@ -156,10 +160,12 @@ export default { item.date = that.dateToString(item.date); }); } catch (e) { + that.submitLoading = false; throw Error(e); } }) .catch((r) => { + that.submitLoading = false; that.$router .push({ path: "/login", diff --git a/src/components/Login.vue b/src/components/Login.vue index c920d68..9fea62b 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -1,6 +1,6 @@