From 10dafc913496811d3b7c1337a1da53b8105f5e6d Mon Sep 17 00:00:00 2001 From: zyxm5 <36184564+zyxm5@users.noreply.github.com> Date: Thu, 16 Sep 2021 17:26:00 +0800 Subject: [PATCH] Update caveats.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在constructor中使用异步函数,只是被调用一次 --- docs/guide/caveats.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/caveats.md b/docs/guide/caveats.md index 6b26be3..6687988 100644 --- a/docs/guide/caveats.md +++ b/docs/guide/caveats.md @@ -64,7 +64,7 @@ export default class Posts extends Vue { } ``` -The above code intends to fetch post list on component initialization but the fetch will be called twice unexpectedly because of how Vue Class Component works. +The above code intends to fetch post list on component initialization but the fetch will be called once unexpectedly because of how Vue Class Component works. It is recommended to write lifecycle hooks such as `created` instead of `constructor`: @@ -85,4 +85,4 @@ export default class Posts extends Vue { }) } } -``` \ No newline at end of file +```