Skip to content

Commit 69b810e

Browse files
dikisiswantomazipan
authored andcommitted
ID Translation of Conditional Rendering page (#57)
* ID Translation of Conditional Rendering page * Update conditional.md
1 parent 0c1b4ce commit 69b810e

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

src/v2/guide/conditional.md

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
---
2-
title: Conditional Rendering
2+
title: Rendering Bersyarat
33
type: guide
44
order: 7
55
---
66

77
## `v-if`
88

9-
The directive `v-if` is used to conditionally render a block. The block will only be rendered if the directive's expression returns a truthy value.
9+
Instruksi `v-if` biasa digunakan untuk melakukan render sebuah blok secara bersyarat. Blok hanya akan di-*render* apabila ekspresi instruksi mengembalikan nilai benar.
1010

1111
``` html
12-
<h1 v-if="awesome">Vue is awesome!</h1>
12+
<h1 v-if="awesome">Vue itu mengagumkan!</h1>
1313
```
1414

15-
It is also possible to add an "else block" with `v-else`:
15+
Juga memungkinkan untuk menambahkan "blok else" dengan `v-else`:
1616

1717
``` html
18-
<h1 v-if="awesome">Vue is awesome!</h1>
19-
<h1 v-else>Oh no 😢</h1>
18+
<h1 v-if="awesome">Vue itu mengagumkan!</h1>
19+
<h1 v-else>Oh tidak 😢</h1>
2020
```
2121

22-
### Conditional Groups with `v-if` on `<template>`
22+
### Pengelompokan Bersyarat dengan `v-if` pada `<template>`
2323

24-
Because `v-if` is a directive, it has to be attached to a single element. But what if we want to toggle more than one element? In this case we can use `v-if` on a `<template>` element, which serves as an invisible wrapper. The final rendered result will not include the `<template>` element.
24+
Sebab `v-if` adalah sebuah instruksi, maka ia harus ditempelkan pada sebuah elemen tunggal. Tetapi bagaimana jika kita ingin beralih lebih dari satu elemen? Dalam kasus ini kita dapat menggunakan `v-if` pada sebuah elemen `<template>`, yang akan bertindak sebagai pembungkus yang tak terlihat. Hasil akhir dari *rendering* tidak akan menyertakan elemen `<template>`.
2525

2626
``` html
2727
<template v-if="ok">
28-
<h1>Title</h1>
29-
<p>Paragraph 1</p>
30-
<p>Paragraph 2</p>
28+
<h1>Judul</h1>
29+
<p>Paragraf 1</p>
30+
<p>Paragraf 2</p>
3131
</template>
3232
```
3333

3434
### `v-else`
3535

36-
You can use the `v-else` directive to indicate an "else block" for `v-if`:
36+
Anda bisa menggunakan instruksi `v-else` untuk menunjukkan sebuah "blok else" untuk `v-if`:
3737

3838
``` html
3939
<div v-if="Math.random() > 0.5">
40-
Now you see me
40+
Sekarang Anda dapat melihatku
4141
</div>
4242
<div v-else>
43-
Now you don't
43+
Sekarang tidak bisa
4444
</div>
4545
```
4646

47-
A `v-else` element must immediately follow a `v-if` or a `v-else-if` element - otherwise it will not be recognized.
47+
Sebuah elemen `v-else` harus berada setelah `v-if` atau setelah elemen `v-else-if` - jika tidak maka ia tidak akan dikenali.
4848

4949
### `v-else-if`
5050

51-
> New in 2.1.0+
51+
> Baru tersedia pada 2.1.0+
5252
53-
The `v-else-if`, as the name suggests, serves as an "else if block" for `v-if`. It can also be chained multiple times:
53+
`v-else-if`, sesuai namanya, bertindak sebagai "blok else if" untuk `v-if`. Ia juga bisa dirangkai berkali-kali:
5454

5555
```html
5656
<div v-if="type === 'A'">
@@ -63,44 +63,44 @@ The `v-else-if`, as the name suggests, serves as an "else if block" for `v-if`.
6363
C
6464
</div>
6565
<div v-else>
66-
Not A/B/C
66+
Bukan A/B/C
6767
</div>
6868
```
6969

70-
Similar to `v-else`, a `v-else-if` element must immediately follow a `v-if` or a `v-else-if` element.
70+
Sama seperti `v-else`, sebuah elemen `v-else-if` harus berada sesudah `v-if` atau sesudah elemen `v-else-if`.
7171

72-
### Controlling Reusable Elements with `key`
72+
### Mengendalikan Elemen Reusable dengan `key`
7373

74-
Vue tries to render elements as efficiently as possible, often re-using them instead of rendering from scratch. Beyond helping make Vue very fast, this can have some useful advantages. For example, if you allow users to toggle between multiple login types:
74+
Vue mencoba me-*render* elemen se-efisien mungkin, lebih sering memakainya kembali dibandingkan melakukan *rendering* dari awal. Itulah mengapa Vue sangat cepat, dimana hal ini memiliki banyak manfaat. Sebagai contoh, jika Anda mengizinkan pengguna untuk beralih antar jenis *login*:
7575

7676
``` html
7777
<template v-if="loginType === 'username'">
7878
<label>Username</label>
79-
<input placeholder="Enter your username">
79+
<input placeholder="Masukkan username Anda">
8080
</template>
8181
<template v-else>
8282
<label>Email</label>
83-
<input placeholder="Enter your email address">
83+
<input placeholder="Masukkan alamat surel Anda">
8484
</template>
8585
```
8686

87-
Then switching the `loginType` in the code above will not erase what the user has already entered. Since both templates use the same elements, the `<input>` is not replaced - just its `placeholder`.
87+
Kemudian peralihan `loginType` pada kode di atas tidak akan menghapus apa yang pengguna telah ketikkan. Karena templat keduanya menggunakan elemen yang sama, `<input>` tidak akan ditimpa - hanya bagian `placeholder`.
8888

89-
Check it out for yourself by entering some text in the input, then pressing the toggle button:
89+
Periksa sendiri dengan memasukkan beberapa teks pada kotak isian, lalu tekan tombol alih:
9090

9191
{% raw %}
9292
<div id="no-key-example" class="demo">
9393
<div>
9494
<template v-if="loginType === 'username'">
9595
<label>Username</label>
96-
<input placeholder="Enter your username">
96+
<input placeholder="Masukkan username Anda">
9797
</template>
9898
<template v-else>
9999
<label>Email</label>
100-
<input placeholder="Enter your email address">
100+
<input placeholder="Masukkan alamat surel Anda">
101101
</template>
102102
</div>
103-
<button @click="toggleLoginType">Toggle login type</button>
103+
<button @click="toggleLoginType">Beralih jenis login</button>
104104
</div>
105105
<script>
106106
new Vue({
@@ -117,7 +117,7 @@ new Vue({
117117
</script>
118118
{% endraw %}
119119

120-
This isn't always desirable though, so Vue offers a way for you to say, "These two elements are completely separate - don't re-use them." Add a `key` attribute with unique values:
120+
Hal ini kadang tidak diinginkan, sehingga Vue menawarkan cara bagi Anda yang bilang, "Dua elemen ini sepenuhnya terpisah - jangan gunakan ulang mereka." Tambahkan sebuah atribut `key` dengan nilai yang unik:
121121

122122
``` html
123123
<template v-if="loginType === 'username'">
@@ -130,21 +130,21 @@ This isn't always desirable though, so Vue offers a way for you to say, "These t
130130
</template>
131131
```
132132

133-
Now those inputs will be rendered from scratch each time you toggle. See for yourself:
133+
Sekarang kotak isian tersebut akan di-*render* dari awal tiap kali tombol alih ditekan. Bisa dilihat di bawah:
134134

135135
{% raw %}
136136
<div id="key-example" class="demo">
137137
<div>
138138
<template v-if="loginType === 'username'">
139139
<label>Username</label>
140-
<input placeholder="Enter your username" key="username-input">
140+
<input placeholder="Masukkan username Anda" key="username-input">
141141
</template>
142142
<template v-else>
143143
<label>Email</label>
144-
<input placeholder="Enter your email address" key="email-input">
144+
<input placeholder="Masukkan alamat surel Anda" key="email-input">
145145
</template>
146146
</div>
147-
<button @click="toggleLoginType">Toggle login type</button>
147+
<button @click="toggleLoginType">Beralih jenis login</button>
148148
</div>
149149
<script>
150150
new Vue({
@@ -161,32 +161,32 @@ new Vue({
161161
</script>
162162
{% endraw %}
163163

164-
Note that the `<label>` elements are still efficiently re-used, because they don't have `key` attributes.
164+
Harap diperhatikan bahwa elemen `<label>` masih digunakan ulang secara efisien, sebab tidak memiliki atribut `key`.
165165

166166
## `v-show`
167167

168-
Another option for conditionally displaying an element is the `v-show` directive. The usage is largely the same:
168+
Opsi lain untuk menampilkan elemen secara bersyarat adalah menggunakan instruksi `v-show`. Penggunaannya kurang lebih sama:
169169

170170
``` html
171-
<h1 v-show="ok">Hello!</h1>
171+
<h1 v-show="ok">Halo!</h1>
172172
```
173173

174-
The difference is that an element with `v-show` will always be rendered and remain in the DOM; `v-show` only toggles the `display` CSS property of the element.
174+
Perbedaannya adalah `v-show` akan selalu melakukan *rendering* dan tetap berada di DOM; `v-show` hanya mengalihkan properti CSS `display` dari elemen tersebut.
175175

176-
<p class="tip">Note that `v-show` doesn't support the `<template>` element, nor does it work with `v-else`.</p>
176+
<p class="tip">Sebagai catatan bahwa `v-show` tidak mendukung elemen `<template>`, begitu pula tidak bekerja dengan `v-else`.</p>
177177

178178
## `v-if` vs `v-show`
179179

180-
`v-if` is "real" conditional rendering because it ensures that event listeners and child components inside the conditional block are properly destroyed and re-created during toggles.
180+
`v-if` merupakan rendering bersyarat yang "nyata (real)" sebab ia memastikan bahwa penyimak *event* dan komponen anak di dalam blok kondisional benar benar dihancurkan dan dibuat ulang selama peralihan.
181181

182-
`v-if` is also **lazy**: if the condition is false on initial render, it will not do anything - the conditional block won't be rendered until the condition becomes true for the first time.
182+
`v-if` juga **malas**: jika kondisi bernilai salah pada render awal, maka tidak akan melakukan apa-apa - blok kondisional tidak akan di-*render* hingga kondisi menjadi bernilai benar untuk pertama kali.
183183

184-
In comparison, `v-show` is much simpler - the element is always rendered regardless of initial condition, with CSS-based toggling.
184+
Sebagai perbandingan, `v-show` jauh lebih sederhana - elemen akan selalu di-*render* tak terkecuali kondisi awal, dengan melakukan peralihan berbasis CSS.
185185

186-
Generally speaking, `v-if` has higher toggle costs while `v-show` has higher initial render costs. So prefer `v-show` if you need to toggle something very often, and prefer `v-if` if the condition is unlikely to change at runtime.
186+
Secara umum, `v-if` memiliki biaya peralihan yang lebih tinggi sementara `v-show` memiliki biaya *rendering* awal yang lebih tinggi. Jadi lebih baik gunakan `v-show` jika Anda butuh pengalihan yang cukup sering, dan gunakan `v-if` if kondisi tidak mungkin berubah saat *runtime*.
187187

188-
## `v-if` with `v-for`
188+
## `v-if` dengan `v-for`
189189

190-
<p class="tip">Using `v-if` and `v-for` together is **not recommended**. See the [style guide](/v2/style-guide/#Avoid-v-if-with-v-for-essential) for further information.</p>
190+
<p class="tip">Menggunakan `v-if` dan `v-for` secara bersama-sama **tidak direkomendasikan**. Lihat [panduan gaya](/v2/style-guide/#Avoid-v-if-with-v-for-essential) untuk informasi lebih lanjut.</p>
191191

192-
When used together with `v-if`, `v-for` has a higher priority than `v-if`. See the <a href="../guide/list.html#V-for-and-v-if">list rendering guide</a> for details.
192+
Ketika menggunakan bersama-sama dengan `v-if`, `v-for` memiliki prioritas yang lebih tinggi dibanding `v-if`. Lihat <a href="../guide/list.html#V-for-and-v-if">panduan list rendering</a> untuk detailnya.

0 commit comments

Comments
 (0)