diff --git a/src/guide/migration/events-api.md b/src/guide/migration/events-api.md index c0b5709b..e3a9de86 100644 --- a/src/guide/migration/events-api.md +++ b/src/guide/migration/events-api.md @@ -3,15 +3,15 @@ badges: - breaking --- -# Events API +# イベント API -## Overview +## 概要 -`$on`, `$off` and `$once` instance methods are removed. Application instances no longer implement the event emitter interface. +インスタンスメソッド`$on`、`$off`、`$once`は削除されました。アプリケーションインスタンスはイベントエミッタインタフェースを実装しなくなりました。 -## 2.x Syntax +## 2.x での構文 -In 2.x, Vue instance could be used to trigger handlers attached imperatively via the event emitter API (`$on`, `$off` and `$once`). This was used to create _event hubs_ to create global event listeners used across the whole application: +2.x では、Vue インスタンスを使用して、イベントエミッタ API (`$on`、`$off`、`$once`) を介して強制的に接続されたハンドラをトリガすることができました。これは、アプリケーション全体で使用されるグローバルイベントリスナーを作成するための _イベントハブ_ を作るために使用されました。 ```js // eventHub.js @@ -27,15 +27,15 @@ import eventHub from './eventHub' export default { mounted() { - // adding eventHub listener + // eventHub リスナーの追加 eventHub.$on('custom-event', () => { console.log('Custom event triggered!') }) }, beforeDestroy() { - // removing eventHub listener + // eventHub リスナーの削除 eventHub.$off('custom-event') - } + }, } ``` @@ -46,18 +46,18 @@ import eventHub from './eventHub' export default { methods: { callGlobalCustomEvent() { - eventHub.$emit('custom-event') // if ChildComponent is mounted, we will have a message in the console - } - } + eventHub.$emit('custom-event') // ChildComponent がマウントされている場合、コンソールにメッセージが表示されます。 + }, + }, } ``` -## 3.x Update +## 3.x での更新 -We removed `$on`, `$off` and `$once` methods from the instance completely. `$emit` is still a part of the existing API as it's used to trigger event handlers declaratively attached by a parent component +インスタンスから`$on`、`$off`、`$once`メソッドを完全に削除しました。`$emit`は、親コンポーネントによって宣言的にアタッチされたイベントハンドラをトリガするために使用されるので、まだ既存の API の一部です。 -## Migration Strategy +## 移行の戦略 -Existing event hubs can be replaced by using an external library implementing the event emitter interface, for example [mitt](https://github.com/developit/mitt). +既存のイベントハブは、イベントエミッタインタフェースを実装した外部ライブラリ、例えば [mitt](https://github.com/developit/mitt) を使用して置き換えることができます。 -These methods can also be supported in compatibility builds. +これらのメソッドは互換性のあるビルドでもサポートされています。