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
Translate Bahasa Indonesia dari : Component Registration (vuejs#62)
* Translate Bahasa Indonesia : Permintaan Vue
* fixed typo and few things
* Update typo
* updated another typo
* updated translation of lifecycle hook
* Translate Bahasa Indonesia : Properti Penghitung & Pengawas
* fixed typos and translation
* Translate Bahasa Indonesia : Component Registrasi
* fixed translation
* fixed translation
Copy file name to clipboardExpand all lines: src/v2/guide/components-registration.md
+43-43Lines changed: 43 additions & 43 deletions
Original file line number
Diff line number
Diff line change
@@ -1,56 +1,56 @@
1
1
---
2
-
title: Component Registration
2
+
title: Registrasi Komponen
3
3
type: guide
4
4
order: 101
5
5
---
6
6
7
-
> This page assumes you've already read the [Components Basics](components.html). Read that first if you are new to components.
7
+
> Halaman ini berasumsi Anda telah membaca [Komponen Dasar](components.html). Baca halaman itu terlebih dahulu bila Anda belum mengerti komponen.
8
8
9
-
## Component Names
9
+
## Nama Komponen
10
10
11
-
When registering a component, it will always be given a name. For example, in the global registration we've seen so far:
11
+
Ketika mendaftarkan sebuah komponen, selalu berikan nama. Misalnya, untuk sebuah registrasi global kita akan melihat seperti berikut:
12
12
13
13
```js
14
14
Vue.component('my-component-name', { /* ... */ })
15
15
```
16
16
17
-
The component's name is the first argument of`Vue.component`.
17
+
Nama komponen adalah argumen pertama dari`Vue.component`.
18
18
19
-
The name you give a component may depend on where you intend to use it. When using a component directly in the DOM (as opposed to in a string template or [single-file component](single-file-components.html)), we strongly recommend following the [W3C rules](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name)for custom tag names (all-lowercase, must contain a hyphen). This helps you avoid conflicts with current and future HTML elements.
19
+
Nama yang Anda berikan ke komponen mungkin tergantung pada dimana Anda akan menggunakannya. Ketika menggunakan komponen secara langsung di dalam DOM ( sebagai lawan di dalam *template string* atau [berkas komponen tunggal *(single-file component)*](single-file-components.html)), kita sangat merekomendasikan untuk mengikuti [Panduan W3C](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name)untuk membuat nama tag *custom* (semuanya huruf kecil, harus berisi tAnda penghubung). Ini membantu Anda untuk menghindari konflik dengan elemen HTML sekarang dan kedepanya.
20
20
21
-
You can see other recommendations for component names in the [Style Guide](../style-guide/#Base-component-names-strongly-recommended).
21
+
Anda bisa melihat rekomendasi lainya untuk nama nama komponen di [Panduan Gaya](../style-guide/#Base-component-names-strongly-recommended).
22
22
23
-
### Name Casing
23
+
### Bingkai Nama (Name Casing)
24
24
25
-
You have two options when defining component names:
25
+
Anda mempunyai dua pilihan ketika mendefinisikan nama komponen:
When defining a component with kebab-case, you must also use kebab-case when referencing its custom element, such as in `<my-component-name>`.
33
+
Ketika mendefinisikan komponen dengan *kebab-case*, Anda juga harus menggunakan *kebab-case* ketika memberi referensi ke elemen *custom*, seperti di `<nama-komponen-saya>`.
34
34
35
-
#### With PascalCase
35
+
#### Dengan *PascalCase*
36
36
37
37
```js
38
-
Vue.component('MyComponentName', { /* ... */ })
38
+
Vue.component('NamaKomponenSaya', { /* ... */ })
39
39
```
40
40
41
-
When defining a component with PascalCase, you can use either case when referencing its custom element. That means both`<my-component-name>`and`<MyComponentName>`are acceptable. Note, however, that only kebab-case names are valid directly in the DOM (i.e. non-string templates).
41
+
Ketika mendefinisikan komponen dengan *PascalCase*, Anda dapat menggunakan kedua hal ketika memberi referensi ke *custom* elemenya. Itu berarti, kedua`<nama-komponen-saya>`dan`<NamaKomponenSaya>`dapat diterima. Catatan, meskipun hanya nama *kebab-case* yang valid secara langsung di DOM (contoh : *templates non-string*).
42
42
43
-
## Global Registration
43
+
## Registrasi Global
44
44
45
-
So far, we've only created components using`Vue.component`:
45
+
Sejauh ini, kita hanya membuat komponen menggunakan`Vue.component`:
46
46
47
47
```js
48
-
Vue.component('my-component-name', {
49
-
// ... options ...
48
+
Vue.component('nama-komponen-saya', {
49
+
// ... pilihan ...
50
50
})
51
51
```
52
52
53
-
These components are **globally registered**. That means they can be used in the template of any root Vue instance (`new Vue`) created after registration. For example:
53
+
Komponen ini **teregistrasi secara global**. Itu berarti mereka dapat digunakan di dalam *template* dari semua *root Vue Instance* (`new Vue`) dibuat setelah diregistrasi. Sebagai contoh:
54
54
55
55
```js
56
56
Vue.component('component-a', { /* ... */ })
@@ -68,21 +68,21 @@ new Vue({ el: '#app' })
68
68
</div>
69
69
```
70
70
71
-
This even applies to all subcomponents, meaning all three of these components will also be available _inside each other_.
71
+
Ini bahkan berlaku kepada semua sub komponen, berarti tiga komponen tersebut juga tersedia _di dalam satu sama lain_.
72
72
73
-
## Local Registration
73
+
## Registrasi Lokal
74
74
75
-
Global registration often isn't ideal. For example, if you're using a build system like Webpack, globally registering all components means that even if you stop using a component, it could still be included in your final build. This unnecessarily increases the amount of JavaScript your users have to download.
75
+
Registrasi global jarang menjadi ideal. Sebagai contoh, ketika Anda menggunakan *build system* seperti Webpack, meregistrasi global semua komponen berarti ketika Anda berhenti menggunakan sebuah komponen, itu juga masih termasuk di *final build* Anda. Ketidakperluan ini menambah banyak Javascript yang harus di unduh oleh pengguna Anda.
76
76
77
-
In these cases, you can define your components as plain JavaScript objects:
77
+
Pada kasus ini, Anda bisa menetapkan komponen Anda sebagai objek Javascript sederhana:
78
78
79
79
```js
80
80
var ComponentA = { /* ... */ }
81
81
var ComponentB = { /* ... */ }
82
82
var ComponentC = { /* ... */ }
83
83
```
84
84
85
-
Then define the components you'd like to use in a `components` option:
85
+
Lalu tetapkan komponen komponen yang akan Anda gunakan di opsi `komponen`
86
86
87
87
```js
88
88
newVue({
@@ -94,9 +94,9 @@ new Vue({
94
94
})
95
95
```
96
96
97
-
For each property in the `components` object, the key will be the name of the custom element, while the value will contain the options object for the component.
97
+
Untuk setiap properti di dalam objek `components`, kuncinya akan menjadi nama dari elemen *custom*, ketika nilai akan berisi pilihan objek dari komponen tersebut.
98
98
99
-
Note that**locally registered components are _not_ also available in subcomponents**. For example, if you wanted `ComponentA` to be available in `ComponentB`, you'd have to use:
99
+
Catat bahwa**komponen yang terdaftar secara lokal juga _tidak_ terdapat di dalam _sub komponen_**. Sebagai contoh, jika Anda ingin `Component A` terdapat di dalam `Component B`, Anda harus menggunakan:
100
100
101
101
```js
102
102
var ComponentA = { /* ... */ }
@@ -109,7 +109,7 @@ var ComponentB = {
109
109
}
110
110
```
111
111
112
-
Or if you're using ES2015 modules, such as through Babel and Webpack, that might look more like:
112
+
Atau jika Anda menggunakan modul ES2015, seperti menggunakan Babel dan Webpack, itu akan lebih terlihat seperti:
113
113
114
114
```js
115
115
importComponentAfrom'./ComponentA.vue'
@@ -122,20 +122,20 @@ export default {
122
122
}
123
123
```
124
124
125
-
Note that in ES2015+, placing a variable name like `ComponentA`inside an object is shorthand for `ComponentA: ComponentA`, meaning the name of the variable is both:
125
+
Catat bahwa di ES2015+, menempatkan nama variabel seperti `ComponentA`di dalam *shorthand* objek untuk`ComponentA: ComponentA`, berarti nama dari kedua variabel adalah:
126
126
127
-
-the custom element name to use in the template, and
128
-
-the name of the variable containing the component options
127
+
-nama elemen *custom* yang digunakan di *template*, dan
128
+
-nama dari variabel berisi pilihan komponen
129
129
130
-
## Module Systems
130
+
## Sistem Modul
131
131
132
-
If you're not using a module system with `import`/`require`, you can probably skip this section for now. If you are, we have some special instructions and tips just for you.
132
+
Ketika Anda tidak menggunakan sistem modul dengan `import`/`require`, Anda mungkin bisa melewati bagian ini untuk sekarang. Jika Anda menggunakanya, kita punya beberapa arahan spesial dan tips khusus untukmu.
133
133
134
-
### Local Registration in a Module System
134
+
### Registrasi Lokal di dalam Sistem Modul
135
135
136
-
If you're still here, then it's likely you're using a module system, such as with Babel and Webpack. In these cases, we recommend creating a `components` directory, with each component in its own file.
136
+
Jika Anda masih disini, berarti sepertinya Anda menggunakan sistem modul, seperti Babel dan Webpack. Pada kasus ini, kita merekomendasi membuat sebuah direktori `komponen`, dengan setiap komponen memiliki filenya sendiri.
137
137
138
-
Then you'll need to import each component you'd like to use, before you locally register it. For example, in a hypothetical `ComponentB.js`or`ComponentB.vue` file:
138
+
Lalu Anda harus memasukan setiap komponen yang akan Anda gunakan, sebelum Anda mendaftarkanya secara lokal. Sebagai contoh, di sebuah *hypothetical*`ComponentB.js`atau`ComponentB.vue` file:
139
139
140
140
```js
141
141
importComponentAfrom'./ComponentA'
@@ -150,13 +150,13 @@ export default {
150
150
}
151
151
```
152
152
153
-
Now both`ComponentA`and`ComponentC`can be used inside `ComponentB`'s template.
153
+
Sekarang kedua`ComponentA`Dan`ComponentC`dapat digunakan di dalam *template*`ComponentB`.
154
154
155
-
### Automatic Global Registration of Base Components
155
+
### Registrasi Otomatis Global dari Komponen Dasar
156
156
157
-
Many of your components will be relatively generic, possibly only wrapping an element like an input or a button. We sometimes refer to these as [base components](../style-guide/#Base-component-names-strongly-recommended)and they tend to be used very frequently across your components.
157
+
Banyak dari komponen Anda akan generik secara relatif, mungkin hanya membungkus elemen seperti sebuah tombol atau *input*. Kita terkadang mengacu pada ini sebagai [komponen dasar](../style-guide/#Base-component-names-strongly-recommended)dan mereka cenderung sering digunakan di beberapa komponen Anda.
158
158
159
-
The result is that many components may include long lists of base components:
159
+
Hasilnya adalah banyak komponen mungkin memasukan daftar panjang dari komponen dasar:
160
160
161
161
```js
162
162
importBaseButtonfrom'./BaseButton.vue'
@@ -172,7 +172,7 @@ export default {
172
172
}
173
173
```
174
174
175
-
Just to support relatively little markup in a template:
175
+
Hanya untuk membantu sedikit *markup* yang sama di sebuah *template*:
176
176
177
177
```html
178
178
<BaseInput
@@ -184,7 +184,7 @@ Just to support relatively little markup in a template:
184
184
</BaseButton>
185
185
```
186
186
187
-
Fortunately, if you're using Webpack (or[Vue CLI 3+](https://github.com/vuejs/vue-cli), which uses Webpack internally), you can use`require.context`to globally register only these very common base components. Here's an example of the code you might use to globally import base components in your app's entry file (e.g.`src/main.js`):
187
+
Untungnya, jika Anda menggunakan Webpack (atau[Vue CLI 3+](https://github.com/vuejs/vue-cli), yang menggunakan Webpack di dalamnya), Anda bisa menggunakan`require.context`untuk mendaftarkan secara global komponen dasar yang paling umum. Berikut ini adalah contoh dari kode yang mungkin Anda gunakan secara global untuk memasukan komponen dasar di awalan file aplikasi milik Anda (contohnya`src/main.js`):
Remember that **global registration must take place before the root Vue instance is created (with`new Vue`)**. [Here's an example](https://github.com/chrisvfritz/vue-enterprise-boilerplate/blob/master/src/components/_globals.js)of this pattern in a real project context.
230
+
Harap diingat bahsaw **pendaftaran global harus terjadi sebelum _root instance Vue_ dibuat (dengan`new Vue`)**. [ Berikut contohnya](https://github.com/chrisvfritz/vue-enterprise-boilerplate/blob/master/src/components/_globals.js)dari pola ini di dalam konteks proyek sungguhan.
0 commit comments