diff --git a/src/comment/ArticleComment.vue b/src/comment/ArticleComment.vue index ec29a00ec1532da2db2d9dc107e76ca1558692cf..dcb76e346c630802c99d207b2c85b472d668e1bc 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 c920d68df847c57d297ae9ba476ed90fcfee8563..9fea62bc9e8cc2782e327e81de0c2e05715dcdc8 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -1,6 +1,6 @@