Skip to content

Commit 3b71333

Browse files
committed
translate Replacing Template Features with Plain JavaScript section
1 parent fc3dd9c commit 3b71333

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

src/guide/render-function.md

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,19 @@ render() {
240240
}
241241
```
242242

243-
## Replacing Template Features with Plain JavaScript
243+
## Substituíndo Templates de recursos por JavaScript Simples
244+
### `v-if` e `v-for`
244245

245-
### `v-if` and `v-for`
246-
247-
Wherever something can be easily accomplished in plain JavaScript, Vue render functions do not provide a proprietary alternative. For example, in a template using `v-if` and `v-for`:
246+
Sempre que algo for facilmente realizado usando JavaScript simples, as funções de renderização do Vue não são uma alternativa apropriada. Por exemplo, em um template usando `v-if` e `v-for`:
248247

249248
```html
250249
<ul v-if="items.length">
251250
<li v-for="item in items">{{ item.name }}</li>
252251
</ul>
253-
<p v-else>No items found.</p>
252+
<p v-else>Não foram encontrados itens.</p>
254253
```
255254

256-
This could be rewritten with JavaScript's `if`/`else` and `map()` in a render function:
255+
Pode ser rescrito usando usando `if`/`else` e `map()` com JavaScript em uma função de renderização:
257256

258257
```js
259258
props: ['items'],
@@ -263,14 +262,14 @@ render() {
263262
return Vue.h('li', item.name)
264263
}))
265264
} else {
266-
return Vue.h('p', 'No items found.')
265+
return Vue.h('p', 'Não foram encontrados itens.')
267266
}
268267
}
269268
```
270269

271270
### `v-model`
272271

273-
The `v-model` directive is expanded to `modelValue` and `onUpdate:modelValue` props during template compilation—we will have to provide these props ourselves:
272+
A diretiva `v-model` é expandida para as propriedades `modelValue`e `onUpdate:modelValue` durante a compilação do template - nós mesmos teremos que prover essas propriedades:
274273

275274
```js
276275
props: ['modelValue'],
@@ -284,7 +283,7 @@ render() {
284283

285284
### `v-on`
286285

287-
We have to provide a proper prop name for the event handler, e.g., to handle `click` events, the prop name would be `onClick`.
286+
Temos que prover o propriedade com nome apropriado para o manipulador do evento, e.g., para manipular um evento de `click`, o nome da propriedade deve ser `onClick`.
288287

289288
```js
290289
render() {
@@ -294,11 +293,11 @@ render() {
294293
}
295294
```
296295

297-
#### Event Modifiers
296+
#### Modificadores de Eventos
298297

299-
For the `.passive`, `.capture`, and `.once` event modifiers, they can be concatenated after event name using camel case.
298+
Os modificadores de evento `.passive`, `.capture` e `.once`, podem ser concatenados após o nome do evento usando grafia camelo (_camel case_).
300299

301-
For example:
300+
Por exemplo:
302301

303302
```javascript
304303
render() {
@@ -310,32 +309,32 @@ render() {
310309
}
311310
```
312311

313-
For all other event and key modifiers, no special API is necessary, because we can use event methods in the handler:
312+
Para todos os outros modificadores de evento, não é necessária nenhuma API especial, pois podemos usar métodos de evento no manipulador:
314313

315-
| Modifier(s) | Equivalent in Handler |
316-
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
317-
| `.stop` | `event.stopPropagation()` |
318-
| `.prevent` | `event.preventDefault()` |
319-
| `.self` | `if (event.target !== event.currentTarget) return` |
320-
| Keys:<br>`.enter`, `.13` | `if (event.keyCode !== 13) return` (change `13` to [another key code](http://keycode.info/) for other key modifiers) |
321-
| Modifiers Keys:<br>`.ctrl`, `.alt`, `.shift`, `.meta` | `if (!event.ctrlKey) return` (change `ctrlKey` to `altKey`, `shiftKey`, or `metaKey`, respectively) |
314+
| Modificador(es) | Equivalente no manipulador |
315+
| -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
316+
| `.stop` | `event.stopPropagation()` |
317+
| `.prevent` | `event.preventDefault()` |
318+
| `.self` | `if (event.target !== event.currentTarget) return` |
319+
| Teclas:<br>`.enter`, `.13` | `if (event.keyCode !== 13) return` (mude `13` para [outro código de tecla](http://keycode.info/) para outro modificador de tecla) |
320+
| Modificadores de teclas:<br>`.ctrl`, `.alt`, `.shift`, `.meta` | `if (!event.ctrlKey) return` (mude `ctrlKey` para `altKey`, `shiftKey`, ou `metaKey`, respectivamente) |
322321

323-
Here's an example with all of these modifiers used together:
322+
Aqui temos um exemplo de todos esses modificadores sendo usados juntos:
324323

325324
```js
326325
render() {
327326
return Vue.h('input', {
328327
onKeyUp: event => {
329-
// Abort if the element emitting the event is not
330-
// the element the event is bound to
328+
// Aborta se o elemento emitindo o evento não é
329+
// o elemento em qual o evento é ligado
331330
if (event.target !== event.currentTarget) return
332-
// Abort if the key that went up is not the enter
333-
// key (13) and the shift key was not held down
334-
// at the same time
331+
// Aborta se a tecla que foi pressionada não é a tecla enter
332+
// (13) e a tecla shift não está sendo segurada
333+
// ao mesmo tempo
335334
if (!event.shiftKey || event.keyCode !== 13) return
336-
// Stop event propagation
335+
// Para a propagação de eventos
337336
event.stopPropagation()
338-
// Prevent the default keyup handler for this element
337+
// Previne o manipulador padrão de teclas para este elemento
339338
event.preventDefault()
340339
// ...
341340
}
@@ -345,7 +344,7 @@ render() {
345344

346345
### Slots
347346

348-
You can access slot contents as Arrays of VNodes from [`this.$slots`](../api/instance-properties.html#slots):
347+
Você pode acessar os conteúdos de slots como Arrays de _VNodes_ através de [`this.$slots`](../api/instance-properties.html#slots):
349348

350349
```js
351350
render() {
@@ -364,15 +363,15 @@ render() {
364363
}
365364
```
366365

367-
To pass slots to a child component using render functions:
366+
Passar slots para um componente filho usando funções de renderização:
368367

369368
```js
370369
render() {
371370
// `<div><child v-slot="props"><span>{{ props.text }}</span></child></div>`
372371
return Vue.h('div', [
373372
Vue.h('child', {}, {
374-
// pass `slots` as the children object
375-
// in the form of { name: props => VNode | Array<VNode> }
373+
// passa `slots` como objetos filhos
374+
// na forma de { name: props => VNode | Array<VNode> }
376375
default: (props) => Vue.h('span', props.text)
377376
})
378377
])

0 commit comments

Comments
 (0)