File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ badges :
3
+ - breaking
4
+ ---
5
+
6
+ # VNode ライフサイクルイベント <MigrationBadges :badges =" $frontmatter.badges " />
7
+
8
+ ## 概要
9
+
10
+ Vue 2 では、イベントを使ってコンポーネントのライフサイクルの重要なステージを監視することができました。これらのイベントは、プレフィックスの ` hook: ` からはじまり、その後にライフサイクルフックの名前がついていました。
11
+
12
+ Vue 3 では、このプレフィックスが ` vnode- ` に変更されました。また、これらのイベントは、コンポーネントとしてだけでなく HTML 要素でも利用できるようになりました。
13
+
14
+ ## 2.x での構文
15
+
16
+ Vue 2 では、イベント名は同等のライフサイクルフックと同じで、プレフィックスに ` hook: ` がついています:
17
+
18
+ ``` html
19
+ <template >
20
+ <child-component @hook:updated =" onUpdated" >
21
+ </template >
22
+ ```
23
+
24
+ ## 3.x での構文
25
+
26
+ Vue 3 では、イベント名のプレフィックスに ` vnode- ` がついています:
27
+
28
+ ``` html
29
+ <template >
30
+ <child-component @vnode-updated =" onUpdated" >
31
+ </template >
32
+ ```
33
+
34
+ またはキャメルケースを使用している場合は、単に ` vnode ` となります:
35
+
36
+ ``` html
37
+ <template >
38
+ <child-component @vnodeUpdated =" onUpdated" >
39
+ </template >
40
+ ```
41
+
42
+ ## 移行の戦略
43
+
44
+ ほとんどの場合、プレフィックスの変更だけで済みます。ライフサイクルフックの ` beforeDestroy ` と ` destroyed ` は、それぞれ ` beforeUnmount ` と ` unmounted ` に名前が変更され、対応するイベント名も更新する必要があります。
45
+
46
+ ## 参照
47
+
48
+ - [ 移行ガイド - イベント API] ( /guide/migration/events-api.html )
You can’t perform that action at this time.
0 commit comments