You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide/migration/events-api.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,15 @@ badges:
3
3
- breaking
4
4
---
5
5
6
-
# Events API <MigrationBadges:badges="$frontmatter.badges" />
6
+
# API de Eventos <MigrationBadges:badges="$frontmatter.badges" />
7
7
8
-
## Overview
8
+
## Visão Geral
9
9
10
-
`$on`, `$off`and`$once`instance methods are removed. Application instances no longer implement the event emitter interface.
10
+
Os métodos `$on`, `$off`e`$once`foram retirados da instância. A instância da aplicação não implementa mais a interface de emissor de eventos.
11
11
12
-
## 2.x Syntax
12
+
## Sintaxe v2.x
13
13
14
-
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:
14
+
Na v2.x, a instância Vue pode ser usada para acionar manipuladores anexados imperativamente por meio da API do emissor de eventos (`$on`, `$off`e`$once`). Isso foi usado para criar _hubs de eventos_ para permitir a escuta de eventos globais usados em todo o aplicativo:
15
15
16
16
```js
17
17
// eventHub.js
@@ -27,13 +27,13 @@ import eventHub from './eventHub'
27
27
28
28
exportdefault {
29
29
mounted() {
30
-
//adding eventHub listener
30
+
//adicionando escutador eventHub
31
31
eventHub.$on('custom-event', () => {
32
-
console.log('Custom event triggered!')
32
+
console.log('Evento customizado disparado!')
33
33
})
34
34
},
35
35
beforeDestroy() {
36
-
//removing eventHub listener
36
+
//removendo o escutador eventHub
37
37
eventHub.$off('custom-event')
38
38
}
39
39
}
@@ -46,18 +46,18 @@ import eventHub from './eventHub'
46
46
exportdefault {
47
47
methods: {
48
48
callGlobalCustomEvent() {
49
-
eventHub.$emit('custom-event') //if ChildComponent is mounted, we will have a message in the console
49
+
eventHub.$emit('custom-event') //Quando o componente ChildComponent for montado, nós teremos uma mensagem no console
50
50
}
51
51
}
52
52
}
53
53
```
54
54
55
-
## 3.x Update
55
+
## Atualização v3.x
56
56
57
-
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
57
+
Removemos os métodos `$on`, `$off`e`$once`da instância completamente. `$emit`ainda é uma parte da API existente, pois é usado para acionar manipuladores de eventos declarativamente anexados por um componente pai.
58
58
59
-
## Migration Strategy
59
+
## Estratégia de Migração
60
60
61
-
Existing event hubs can be replaced by using an external library implementing the event emitter interface, for example[mitt](https://github.com/developit/mitt)or[tiny-emitter](https://github.com/scottcorgan/tiny-emitter).
61
+
Os _hubs de eventos_ existentes podem ser substituídos usando uma biblioteca externa implementando a interface do emissor de eventos, por exemplo[mitt](https://github.com/developit/mitt)ou[tiny-emitter](https://github.com/scottcorgan/tiny-emitter).
62
62
63
-
These methods can also be supported in compatibility builds.
63
+
Esses métodos também podem ser suportados em compilações de compatibilidade.
0 commit comments