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
> This section uses [single-file component](../guide/single-file-component.html)syntax for code examples
3
+
> Esta seção usa sintaxe de [componente de arquivo único](../guide/single-file-component.html)para exemplos de código
4
4
5
5
## `reactive`
6
6
7
-
Returns a reactive copy of the object.
7
+
Retorna uma cópia reativa do objeto.
8
8
9
9
```js
10
10
constobj=reactive({ count:0 })
11
11
```
12
12
13
-
The reactive conversion is "deep"—it affects all nested properties. In the [ES2015 Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) based implementation, the returned proxy is**not**equal to the original object. It is recommended to work exclusively with the reactive proxy and avoid relying on the original object.
13
+
A conversão reativa é "profunda" - ela afeta todas as propriedades aninhadas. Na implementação baseada em [ES2015 Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy), o proxy retornado**não**é igual ao objeto original. Recomenda-se trabalhar exclusivamente com o proxy reativo e evitar depender do objeto original.
14
14
15
-
**Typing:**
15
+
**Digitando:**
16
16
17
17
```ts
18
18
function reactive<Textendsobject>(target:T):UnwrapNestedRefs<T>
19
19
```
20
20
21
21
## `readonly`
22
22
23
-
Takesanobject (reactiveorplain) ora [ref](./refs-api.html#ref) andreturnsareadonlyproxytotheoriginal. Areadonlyproxyisdeep: anynestedpropertyaccessedwillbereadonlyaswell.
23
+
Capturaumobjeto (reativoousimples) ouuma [ref](./refs-api.html#ref) eretornaumproxysomenteleituraparaooriginal. Umproxysomenteleitura é profundo: qualquerpropriedadeaninhadaacessadatambémserá somenteleitura
24
24
25
25
```js
26
26
const original = reactive({ count: 0 })
27
27
28
28
const copy = readonly(original)
29
29
30
30
watchEffect(() => {
31
-
// works for reactivity tracking
31
+
// realizando o rastreamento da reatividade
32
32
console.log(copy.count)
33
33
})
34
34
35
-
// mutating original will trigger watchers relying on the copy
35
+
// a mutação do "original" fará com que os observadores confiem na cópia
36
36
original.count++
37
37
38
-
// mutating the copy will fail and result in a warning
38
+
// alterar a cópia irá falhar e resultará em um aviso
39
39
copy.count++ // warning!
40
40
```
41
41
42
42
## `isProxy`
43
43
44
-
Checksifanobjectisaproxycreatedby [`reactive`](#reactive) or [`readonly`](#readonly).
44
+
Verificaseumobjeto é umproxycriadopor [`reactive`](#reactive) ou [`readonly`](#readonly).
Verificaseumobjeto é umproxysomentedeleituracriadopor [`readonly`](#readonly).
87
87
88
88
## `toRaw`
89
89
90
-
Returnstheraw, originalobjectofa [`reactive`](#reactive) or [`readonly`](#readonly)proxy. Thisisanescapehatchthatcanbeusedtotemporarilyreadwithoutincurringproxyaccess/trackingoverheadorwritewithouttriggeringchanges. Itis**not**recommendedtoholdapersistentreferencetotheoriginalobject. Usewithcaution.
90
+
Retornaoobjetobrutooriginaldeumproxy [`reactive`](#reactive) ou [`readonly`](#readonly). Esta é uma"válvula de escape"quepodeserusadaparalertemporariamentesemincorreremacessodeproxy/sobrecargaderastreamentoougravaçãosemacionaralterações. **Não**é recomendadomanterumareferênciapersistenteaoobjetooriginal. Usecomcuidado
//although `foo` is marked as raw, foo.nested is not.
127
+
// embora`foo`esteja marcado como bruto, foo.nested não está.
128
128
nested: foo.nested
129
129
})
130
130
131
131
console.log(foo.nested === bar.nested) // false
132
132
```
133
133
134
-
Identity hazards are in general rare. However, to properly utilize these APIs while safely avoiding identity hazards requires a solid understanding of how the reactivity system works.
134
+
Riscosdeidentidadesãogeralmenteraros. Noentanto, parautilizaradequadamenteessasAPIseaomesmotempoevitarriscosdeidentidade, é necessárioumconhecimentosólidodecomofuncionaosistemadereatividade.
135
135
:::
136
136
137
137
## `shallowReactive`
138
138
139
-
Creates a reactive proxy that tracks reactivity of its own properties but does not perform deep reactive conversion of nested objects (exposes raw values).
0 commit comments