Skip to content

Commit b523269

Browse files
iqbalaqabamazipan
authored andcommitted
Translate Bahasa Indonesia : Vue Instance (#51)
* Translate Bahasa Indonesia : Permintaan Vue * fixed typo and few things * Update typo * updated another typo * updated translation of lifecycle hook
1 parent 69b810e commit b523269

File tree

1 file changed

+46
-35
lines changed

1 file changed

+46
-35
lines changed

src/v2/guide/instance.md

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
---
2-
title: The Vue Instance
2+
title: Vue Instance
33
type: guide
44
order: 3
55
---
66

7-
## Creating a Vue Instance
7+
## Membuat *Vue Instance*
88

9-
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 :
1010

1111
```js
1212
var vm = new Vue({
13-
// options
13+
// pilihan
1414
})
1515
```
1616

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.
1818

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).
2019

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+
2225

2326
```
2427
Root Instance
@@ -31,42 +34,46 @@ Root Instance
3134
└─ TodoListStatistics
3235
```
3336

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*).
3538

36-
## Data and Methods
3739

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+
3944

4045
```js
41-
// Our data object
46+
// Objek data kita
4247
var data = { a: 1 }
4348

44-
// The object is added to a Vue instance
49+
// Objek ditambahkan kedalam Vue Instance
4550
var vm = new Vue({
4651
data: data
4752
})
4853

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
5156
vm.a == data.a // => true
5257

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
5560
vm.a = 2
5661
data.a // => 2
5762

58-
// ... and vice-versa
63+
// ... dan kebalikanya
5964
data.a = 3
6065
vm.a // => 3
6166
```
6267

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+
6470

6571
```js
66-
vm.b = 'hi'
72+
vm.b = 'halo'
6773
```
6874

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+
7077

7178
```js
7279
data: {
@@ -78,7 +85,8 @@ data: {
7885
}
7986
```
8087

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.
89+
8290

8391
```js
8492
var obj = {
@@ -96,12 +104,13 @@ new Vue({
96104
```html
97105
<div id="app">
98106
<p>{{ foo }}</p>
99-
<!-- this will no longer update `foo`! -->
107+
<!-- ini tidak akan lagi mengubah `foo`! -->
100108
<button v-on:click="foo = 'baz'">Change it</button>
101109
</div>
102110
```
103111

104-
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:
113+
105114

106115
```js
107116
var data = { a: 1 }
@@ -113,39 +122,41 @@ var vm = new Vue({
113122
vm.$data === data // => true
114123
vm.$el === document.getElementById('example') // => true
115124

116-
// $watch is an instance method
125+
// $watch adalah metode instance
117126
vm.$watch('a', function (newValue, oldValue) {
118-
// This callback will be called when `vm.a` changes
127+
// Panggilan balik (callback) ini akan di panggil ketika `vm.a` berubah
119128
})
120129
```
121130

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.
123132

124-
## Instance Lifecycle Hooks
125133

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*
127135

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:
129139

130140
```js
131141
new Vue({
132142
data: {
133143
a: 1
134144
},
135145
created: function () {
136-
// `this` points to the vm instance
146+
// `this` menunjuk ke poin instance vm
137147
console.log('a is: ' + this.a)
138148
}
139149
})
140150
// => "a is: 1"
141151
```
142152

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+
<p class="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>
144156

145-
<p class="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
146158

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
148160

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.
150161

151-
![The Vue Instance Lifecycle](/images/lifecycle.png)
162+
![The *Vue Instance* Lifecycle](/images/lifecycle.png)

0 commit comments

Comments
 (0)