Skip to content

Commit d10464d

Browse files
ikrydevmazipan
authored andcommitted
VDOM, createElement , Data Object (#183)
1 parent bcb50f8 commit d10464d

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

src/v2/guide/render-function.md

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -123,36 +123,36 @@ Dalam kedua kasus, Vue secara otomatis akan memastikan bahwa tampilannya diperba
123123

124124
### The Virtual DOM
125125

126-
Vue accomplishes this by building a **virtual DOM** to keep track of the changes it needs to make to the real DOM. Taking a closer look at this line:
126+
Vue melakukannya dengan cara membuat **virtual DOM** untuk mencatat perubahan yang dibutuhkan untuk merekonstruksi DOM yang sebenarnya. Lihat baris kode di bawah :
127127

128128
``` js
129129
return createElement('h1', this.blogTitle)
130130
```
131131

132-
What is `createElement` actually returning? It's not _exactly_ a real DOM element. It could perhaps more accurately be named `createNodeDescription`, as it contains information describing to Vue what kind of node it should render on the page, including descriptions of any child nodes. We call this node description a "virtual node", usually abbreviated to **VNode**. "Virtual DOM" is what we call the entire tree of VNodes, built by a tree of Vue components.
132+
Apa yang sebenarnya `createElement` kembalikan? hal itu bukanlah elemen DOM yang benar-benar diproses oleh browser. Secara teknis, lebih akurat jika dinamakan `createNodeDescription`, karena berisi informasi yang dibutuhkan oleh Vue, jenis node apa yang harus ditampilkan; termasuk deskripsi ini dari node tersebut. Deskripsi node ini diistilahkan dengan "virtual node", biasanya disingkat **VNode**. Sedangkan "Virtual DOM" digunakan untuk merujuk ke kumpulan dari VNode secara keseluruhan.
133133

134-
## `createElement` Arguments
134+
## Argumen `createElement`
135135

136-
The next thing you'll have to become familiar with is how to use template features in the `createElement` function. Here are the arguments that `createElement` accepts:
136+
Untuk lebih mendalami bagaimana cara penggunaan fitur templat di fungsi `createElement`, berikut beberapa argumen yang diterima oleh `createElement`:
137137

138138
``` js
139139
// @returns {VNode}
140140
createElement(
141141
// {String | Object | Function}
142-
// An HTML tag name, component options, or async
143-
// function resolving to one of these. Required.
142+
// Nama tag HTML, opsi komponen, atau fungsi asinkronus
143+
// Fungsi resolving ke salah satu. Wajib.
144144
'div',
145145

146146
// {Object}
147-
// A data object corresponding to the attributes
148-
// you would use in a template. Optional.
147+
// Objek data yang terkait dengan atribut
148+
// Anda akan gunakan dalam templat. Opsional.
149149
{
150-
// (see details in the next section below)
150+
// (lihat detail di bagian selanjutnya)
151151
},
152152

153153
// {String | Array}
154-
// Children VNodes, built using `createElement()`,
155-
// or using strings to get 'text VNodes'. Optional.
154+
// Isi VNode, bisa dengan `createElement()`,
155+
// atau string sepert 'text VNodes'. Opsional.
156156
[
157157
'Some text comes first.',
158158
createElement('h1', 'A headline'),
@@ -167,50 +167,49 @@ createElement(
167167

168168
### The Data Object In-Depth
169169

170-
One thing to note: similar to how `v-bind:class` and `v-bind:style` have special treatment in templates, they have their own top-level fields in VNode data objects. This object also allows you to bind normal HTML attributes as well as DOM properties such as `innerHTML` (this would replace the `v-html` directive):
170+
Penting untuk dicatat, sama halnya `v-bind:class` dan `v-bind:style` diperlakukan secara khusus di templat, mereka punya tempat tersendiri juga di objek data dari VNode. Lewat objek ini kalian juga melakukan proses *binding* ke atribut bawaan HTML juga properti DOM seperti `innerHTML` (menggantikan direktif `v-html`):
171171

172172
``` js
173173
{
174-
// Same API as `v-bind:class`, accepting either
175-
// a string, object, or array of strings and objects.
174+
// Sama seperti `v-bind:class`, bisa diisi dengan
175+
// string, objek, atau array dari string dan objek
176176
class: {
177177
foo: true,
178178
bar: false
179179
},
180-
// Same API as `v-bind:style`, accepting either
181-
// a string, object, or array of objects.
180+
// Sama seperti `v-bind:style`, bisa diisi dengan
181+
// string, objek, atau array dari objek
182182
style: {
183183
color: 'red',
184184
fontSize: '14px'
185185
},
186-
// Normal HTML attributes
186+
// Atribut bawaan HTML
187187
attrs: {
188188
id: 'foo'
189189
},
190-
// Component props
190+
// properti komponen
191191
props: {
192192
myProp: 'bar'
193193
},
194-
// DOM properties
194+
// properti DOM
195195
domProps: {
196196
innerHTML: 'baz'
197197
},
198-
// Event handlers are nested under `on`, though
199-
// modifiers such as in `v-on:keyup.enter` are not
200-
// supported. You'll have to manually check the
201-
// keyCode in the handler instead.
198+
// Event handler diletakkan di dalam `on`, meskipun
199+
// modifier sepeti `v-on:keyup.enter` tidak
200+
// didukung. Anda harus melakukan pemeriksaan manual
201+
// untuk keyCodenya.
202202
on: {
203203
click: this.clickHandler
204204
},
205-
// For components only. Allows you to listen to
206-
// native events, rather than events emitted from
207-
// the component using `vm.$emit`.
205+
// Hanya untuk komponen, digunakan untuk memperhatikan
206+
// event bawaan, selain dari event yang dihasilkan oleh
207+
// komponen yang menggunakan `vm.$emit`.
208208
nativeOn: {
209209
click: this.nativeClickHandler
210210
},
211-
// Custom directives. Note that the `binding`'s
212-
// `oldValue` cannot be set, as Vue keeps track
213-
// of it for you.
211+
// Direktif kustom. Ingat bahwa `oldValue` tidak bisa diisi secara manual
212+
// Karena Vue akan mengaturnya sendiri.
214213
directives: [
215214
{
216215
name: 'my-custom-directive',
@@ -222,19 +221,19 @@ One thing to note: similar to how `v-bind:class` and `v-bind:style` have special
222221
}
223222
}
224223
],
225-
// Scoped slots in the form of
224+
// Scoped slots dalam bentuk
226225
// { name: props => VNode | Array<VNode> }
227226
scopedSlots: {
228227
default: props => createElement('span', props.text)
229228
},
230-
// The name of the slot, if this component is the
231-
// child of another component
229+
// Nama dari slot, jika komponen ini
230+
// anak dari komponen lain
232231
slot: 'name-of-slot',
233-
// Other special top-level properties
232+
// Properti khusus lainnya
234233
key: 'myKey',
235234
ref: 'myRef',
236-
// If you are applying the same ref name to multiple
237-
// elements in the render function. This will make `$refs.myRef` become an
235+
// Jika kalian menggunakan nama ref yang sama
236+
// di beberapa tempat, nilai dari `$refs.myRef` akan berbentuk
238237
// array
239238
refInFor: true
240239
}

0 commit comments

Comments
 (0)