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/v2/guide/render-function.md
+20-19Lines changed: 20 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
---
2
-
title: Render Functions & JSX
2
+
title: Fungsi *Render* % JSX
3
3
type: guide
4
4
order: 303
5
5
---
6
6
7
7
## Basics
8
8
9
-
Vue recommends using templates to build your HTML in the vast majority of cases. There are situations however, where you really need the full programmatic power of JavaScript. That's where you can use the **render function**, a closer-to-the-compiler alternative to templates.
9
+
Pada banyak kasus, Vue menganjurkan penggunaan templat untuk membuat HTML. Tetapi, ada beberapa situasi di mana anda butuh menggunakan Javascript secara penuh. Kalian bisa menggunakan **fungsi render**, sebagai alternatif dari templat.
10
10
11
-
Let's dive into a simple example where a `render` function would be practical. Say you want to generate anchored headings:
11
+
Mari Lihat contoh sederhana di mana fungsi 'render' terlihat praktis. Katakanlah anda ingin menghasilkan *anchored headings*:
12
12
13
13
```html
14
14
<h1>
@@ -18,13 +18,13 @@ Let's dive into a simple example where a `render` function would be practical. S
18
18
</h1>
19
19
```
20
20
21
-
For the HTML above, you decide you want this component interface:
21
+
Dari HTML di atas, anda memutuskan untuk menggunakan komponen di atas seperti:
That template doesn't feel great. It's not only verbose, but we're duplicating `<slot></slot>` for every heading level and will have to do the same when we add the anchor element.
64
+
Templat di atas tidak telihat bagus, dan banyak sekali duplikasi di dalamnya seperti penggunaan `<slot></slot>` di setiap level heading dan harus melakukan hal yang sama ketika kita menambahkan elemen *anchor*.
65
+
66
+
Sementara templat bekerja dengan baik untuk sebagian besar komponen, jelas penggunaanya masih kurang tepat. Mari kita coba tulis ulang dengan menggunakan fungsi `render`:
65
67
66
-
While templates work great for most components, it's clear that this isn't one of them. So let's try rewriting it with a `render` function:
Much simpler! Sort of. The code is shorter, but also requires greater familiarity with Vue instance properties. In this case, you have to know that when you pass children without a `slot` attribute into a component, like the `Hello world!`inside of`anchored-heading`, those children are stored on the component instance at `$slots.default`. If you haven't already, **it's recommended to read through the [instance properties API](../api/#Instance-Properties)before diving into render functions.**
86
+
Lebih sederhana! kodenya lebih pendek, tapi kita juga harus terbiasa dengan properti yang ada di dalam *Vue instance*. Dalam kasus ini, anda harus tahu bahwa isi dari komponen yang tidak di tandai direktif `v-slot`, seperti `Hello World!`di dalam`anchored-heading`, isi tersebut disimpan di `$slots.default`. Jika anda masih belum paham, **direkomendasikan untuk membaca [instance properties API](../api/#Instance-Properties)sebelum mempelajari lebih dalam tentang fungsi render.**
86
87
87
-
## Nodes, Trees, and the Virtual DOM
88
+
## *Nodes*, *Trees*, dan *Virtual DOM*
88
89
89
-
Before we dive into render functions, it’s important to know a little about how browsers work. Take this HTML for example:
90
+
Sebelum kita lanjut lebih dalam tentang fungsi *render*, penting untuk sedikit mengetahui tentang bagaimana _browsers_ bekeerja. Lihat contoh HTM di bawah:
90
91
91
92
```html
92
93
<div>
@@ -96,29 +97,29 @@ Before we dive into render functions, it’s important to know a little about ho
96
97
</div>
97
98
```
98
99
99
-
When a browser reads this code, it builds a [tree of "DOM nodes"](https://javascript.info/dom-nodes)to help it keep track of everything, just as you might build a family tree to keep track of your extended family.
100
+
Ketika *browser* membaca kode di atas, *browser* akan membuat [pohon yang terdiri atas *DOM nodes*](https://javascript.info/dom-nodes)untuk membantu mencatat isi HTML tersebut, sama seperti jika anda membuat silsilah pohon keluarga untuk mencata isi dari keluarga anda.
100
101
101
-
The tree of DOM nodes for the HTML above looks like this:
102
+
Bentuk pohon dari *DOM nodes* untuk HTML di atas terlihat seperti:
102
103
103
-

104
+

104
105
105
-
Every element is a node. Every piece of text is a node. Even comments are nodes! A node is just a piece of the page. And as in a family tree, each node can have children (i.e. each piece can contain other pieces).
106
+
Setiap elemen adalah *node*. Setiap teks adalah node. BAhkan komentar juga *node*!. Dan sama seperti silsilah keluarga, setiap *node* bisa memiliki anak (misalnya setiap node mengandung *node* lainnya).
106
107
107
-
Updating all these nodes efficiently can be difficult, but thankfully, you never have to do it manually. Instead, you tell Vue what HTML you want on the page, in a template:
108
+
Memperbarui *node* yang banyak ini secara eisien tidaklah mudah, tapi untungnya, anda tidak harus melakukannya secara manual. Sebaliknya, gunakan Vue untuk membuat HTML yang kalian inginkan melalui templat:
108
109
109
110
```html
110
111
<h1>{{ blogTitle }}</h1>
111
112
```
112
113
113
-
Or a render function:
114
+
Atau fungsi *render*:
114
115
115
116
```js
116
117
render:function (createElement) {
117
118
returncreateElement('h1', this.blogTitle)
118
119
}
119
120
```
120
121
121
-
And in both cases, Vue automatically keeps the page updated, even when`blogTitle`changes.
122
+
Dalam kedua kasus, Vue secara otomatis akan memastikan bahwa tampilannya diperbarui dengan benar, seperti ketika`blogTitle`berubah.
0 commit comments