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
Every Vue application starts by creating a new **Vue instance**with the`Vue`function:
9
+
Setiap aplikasi Vue dimulai dengan membuat **Vue Instance**dengan fungsi`Vue`seperti berikut :
10
10
11
11
```js
12
12
var vm =newVue({
13
-
//options
13
+
//pilihan
14
14
})
15
15
```
16
16
17
-
Although not strictly associated with the [MVVM pattern](https://en.wikipedia.org/wiki/Model_View_ViewModel), Vue's design was partly inspired by it. As a convention, we often use the variable `vm` (short for ViewModel) to refer to our Vue instance.
17
+
Meskipun tidak terkait ketat dengan [Pola MVVM](https://en.wikipedia.org/wiki/Model_View_ViewModel), desain yang dimiliki Vue sebagian terinspirasi oleh konsep tersebut. Sebagai ketentuan, kita kadang menggunakan variabel `vm` ( kependekan dari ViewModel ) untuk mengacu pada *Vue Instance* kami.
18
18
19
-
When you create a Vue instance, you pass in an **options object**. The majority of this guide describes how you can use these options to create your desired behavior. For reference, you can also browse the full list of options in the [API reference](../api/#Options-Data).
20
19
21
-
A Vue application consists of a **root Vue instance** created with `new Vue`, optionally organized into a tree of nested, reusable components. For example, a todo app's component tree might look like this:
20
+
Ketika Anda membuat *Vue Instance*, Anda mengirimkan **obyek pilihan**. Sebagian besar dari panduan ini menjelaskan bagaimana Anda bisa menggunakan pilihan ini untuk membuat tindakan yang Anda inginkan. Sebagai contoh, Anda juga bisa melihat lihat daftar lengkap dari pilihan ini di [Contoh API](../api/#Options-Data).
21
+
22
+
23
+
Sebuah aplikasi Vue terdiri dari ***instance* dasar Vue** yang dibuat dengan `new Vue`, secara opsional di atur ke dalam akar (root) *Vue Instance*, komponen yang bisa digunakan ulang. Sebagai contoh, komponen aplikasi pengingat mungkin terlihat seperti ini :
24
+
22
25
23
26
```
24
27
Root Instance
@@ -31,42 +34,46 @@ Root Instance
31
34
└─ TodoListStatistics
32
35
```
33
36
34
-
We'll talk about [the component system](components.html)in detail later. For now, just know that all Vue components are also Vue instances, and so accept the same options object (except for a few root-specific options).
37
+
Kita akan membicarakan tentang [sistem komponen](components.html)pada detail selanjutnya. Sekarang, dengan hanya mengetahui bahwa semua komponen Vue juga adalah *Vue Instance*, dan juga menerima pilihan objek yang sama (kecuali untuk beberapa pilihan *tree of nested*).
35
38
36
-
## Data and Methods
37
39
38
-
When a Vue instance is created, it adds all the properties found in its `data` object to Vue's **reactivity system**. When the values of those properties change, the view will "react", updating to match the new values.
40
+
## Data dan Metode
41
+
42
+
Ketika *Vue Instance* dibuat, ini menambah semua properti yang ditemukan di dalam objek `data` ke **sistem reaktif** milik Vue. Ketika nilai dari properti tersebut berubah, tampilanya akan "bereaksi", memperbarui untuk mencocokan dengan nilai yang baru.
43
+
39
44
40
45
```js
41
-
//Our data object
46
+
//Objek data kita
42
47
var data = { a:1 }
43
48
44
-
//The object is added to a Vue instance
49
+
//Objek ditambahkan kedalam Vue Instance
45
50
var vm =newVue({
46
51
data: data
47
52
})
48
53
49
-
//Getting the property on the instance
50
-
//returns the one from the original data
54
+
//Mendapat properti dari instance
55
+
//lalu mengembalikan dari data asli
51
56
vm.a==data.a// => true
52
57
53
-
//Setting the property on the instance
54
-
//also affects the original data
58
+
//Mengatur properti pada instance
59
+
//yang juga berdampak pada data asli
55
60
vm.a=2
56
61
data.a// => 2
57
62
58
-
// ... and vice-versa
63
+
// ... dan kebalikanya
59
64
data.a=3
60
65
vm.a// => 3
61
66
```
62
67
63
-
When this data changes, the view will re-render. It should be noted that properties in `data` are only **reactive** if they existed when the instance was created. That means if you add a new property, like:
68
+
Ketika data ini berubah, tampilanya akan berubah. Itu harus dicatat bahwa properti di `data` adalah yang satu satunya **reaktif** jika mereka ada pada saat *instance* dibuat. Itu berarti kamu harus menambah properti baru, seperti:
69
+
64
70
65
71
```js
66
-
vm.b='hi'
72
+
vm.b='halo'
67
73
```
68
74
69
-
Then changes to `b` will not trigger any view updates. If you know you'll need a property later, but it starts out empty or non-existent, you'll need to set some initial value. For example:
75
+
Lalu mengubah ke `b` tidak akan memicu perubahan lain pada tampilan. Jika Anda mengetahui bahwa Anda memerlukan properti nanti, tapi ini dimulai dengan kosong atau tidak ada, Anda harus memberi beberapa nilai awal. Sebagai contoh:
76
+
70
77
71
78
```js
72
79
data: {
@@ -78,7 +85,8 @@ data: {
78
85
}
79
86
```
80
87
81
-
The only exception to this being the use of `Object.freeze()`, which prevents existing properties from being changed, which also means the reactivity system can't _track_ changes.
88
+
Satu satunya pengecualian untuk ini adalah menggunakan `Object.freeze()`, yang mencegah properti untuk diubah, yang juga berarti reaktifitas sistem yang tidak bisa _melacak_ perubahan.
In addition to data properties, Vue instances expose a number of useful instance properties and methods. These are prefixed with `$` to differentiate them from user-defined properties. For example:
112
+
Untuk tambahan ke data properti, *Vue Instance* menunjukan sejumlah properti *instance* dan metode yang berguna. Ini juga diawalai dengan `$` untuk membedakan mereka dari properti yang ditetapkan pengguna. Sebagai contoh:
//This callback will be called when `vm.a` changes
127
+
//Panggilan balik (callback) ini akan di panggil ketika `vm.a` berubah
119
128
})
120
129
```
121
130
122
-
In the future, you can consult the [API reference](../api/#Instance-Properties)for a full list of instance properties and methods.
131
+
Selanjutnya, Anda bisa berkonsultasi ke [Referensi API](../api/#Instance-Properties)untuk daftar lengkap dari metode dan properti instance.
123
132
124
-
## Instance Lifecycle Hooks
125
133
126
-
Each Vue instance goes through a series of initialization steps when it's created - for example, it needs to set up data observation, compile the template, mount the instance to the DOM, and update the DOM when data changes. Along the way, it also runs functions called **lifecycle hooks**, giving users the opportunity to add their own code at specific stages.
134
+
## Siklus Hidup Pengait (Lifecycle Hook) *instance*
127
135
128
-
For example, the [`created`](../api/#created) hook can be used to run code after an instance is created:
136
+
Setiap *Vue Instance* melewati beberapa serangkaian langkan inisiasi pada saat dibuat - sebagai contoh, ini perlu diatur observasi data, memproses templat, memasang *instance* ke DOM, dan memperbarui DOM ketika data berubah. Sepanjang proses, ini juga berjalan dengan fungsi bernama **siklus hidup pengait (Lifecycle Hook)**, memberi pengguna kesempatan untuk menambah kode mereka sendiri pada tahapan tertentu.
137
+
138
+
Sebagai contoh, pengait [`created`](../api/#created) bisa digunakan untuk menjalankan kode setelah *instance* ini dibuat:
129
139
130
140
```js
131
141
newVue({
132
142
data: {
133
143
a:1
134
144
},
135
145
created:function () {
136
-
// `this` points to the vm instance
146
+
// `this` menunjuk ke poin instance vm
137
147
console.log('a is: '+this.a)
138
148
}
139
149
})
140
150
// => "a is: 1"
141
151
```
142
152
143
-
There are also other hooks which will be called at different stages of the instance's lifecycle, such as [`mounted`](../api/#mounted), [`updated`](../api/#updated), and [`destroyed`](../api/#destroyed). All lifecycle hooks are called with their `this` context pointing to the Vue instance invoking it.
153
+
Ada juga pengait lain yang akan dipanggil pada tahapan berbeda di siklus hidup *instance*, seperti [`mounted`](../api/#mounted), [`updated`](../api/#updated), dan [`destroyed`](../api/#destroyed). Semua siklus hidup pengait (Lifecycle Hook) dipanggil dengan konteks `this` mereka yang menunjuk ke konteks *Vue Instance* yang menjalankanya.
154
+
155
+
<pclass="tip">Jangan menggunakan [fungsi panah](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions) pada pilihan properti atau pemanggilan ulang, seperti `created: () => console.log(this.a)` or `vm.$watch('a', newValue => this.myMethod())`. Sejak fungsi panah terikat dengan konteks induk, `this` tidak akan menjadi *Vue Instance* seperti yang Anda harapkan, kadang menyebabkan kesalahan seperti `Uncaught TypeError: Cannot read property of undefined` atau `Uncaught TypeError: this.myMethod is not a function`.</p>
144
156
145
-
<pclass="tip">Don't use [arrow functions](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions) on an options property or callback, such as `created: () => console.log(this.a)` or `vm.$watch('a', newValue => this.myMethod())`. Since arrow functions are bound to the parent context, `this` will not be the Vue instance as you'd expect, often resulting in errors such as `Uncaught TypeError: Cannot read property of undefined` or `Uncaught TypeError: this.myMethod is not a function`.</p>
157
+
## Diagram Siklus Hidup
146
158
147
-
## Lifecycle Diagram
159
+
Dibawah ini adalah diagram dari siklus hidup *instance*. Anda tidak perlu memahami dengan penuh apapun yang terjadi sekarang, tapi selama Anda belajar dan terus membuat, ini akan menjadi referensi yang berguna
148
160
149
-
Below is a diagram for the instance lifecycle. You don't need to fully understand everything going on right now, but as you learn and build more, it will be a useful reference.
0 commit comments