Skip to content

Commit e784916

Browse files
padcomchrisvfritz
authored andcommitted
Added information which naming conventions explanation on which naming convention match declaration and usage (vuejs#896)
1 parent 5af1b7a commit e784916

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/v2/guide/components.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ Note that when used as a route component in `vue-router`, these properties will
11281128

11291129
### Component Naming Conventions
11301130

1131-
When registering components (or props), you can use kebab-case, camelCase, or TitleCase. Vue doesn't care.
1131+
When registering components (or props), you can use kebab-case, camelCase, or TitleCase.
11321132

11331133
``` js
11341134
// in a component definition
@@ -1151,15 +1151,33 @@ Within HTML templates though, you have to use the kebab-case equivalents:
11511151
<title-cased-component></title-cased-component>
11521152
```
11531153

1154-
When using _string_ templates however, we're not bound by HTML's case-insensitive restrictions. That means even in the template, you can reference your components and props using camelCase, TitleCase, or kebab-case:
1154+
When using _string_ templates however, we're not bound by HTML's case-insensitive restrictions. That means even in the template, you can reference your components using:
1155+
1156+
- kebab-case
1157+
- camelCase or kebab-case if the component has been defined using camelCase
1158+
- kebab-case, camelCase or Title case if the component has been defined using TitleCase
1159+
1160+
``` js
1161+
components: {
1162+
'kebab-case-component': { /* ... */ },
1163+
camelCaseComponent: { /* ... */ },
1164+
TitleCaseComponent: { /* ... */ }
1165+
}
1166+
```
11551167

11561168
``` html
1157-
<!-- use whatever you want in string templates! -->
1158-
<my-component></my-component>
1159-
<myComponent></myComponent>
1160-
<MyComponent></MyComponent>
1169+
<kebab-case-component />
1170+
1171+
<camel-case-component />
1172+
<camelCaseComponent />
1173+
1174+
<title-case-component />
1175+
<titleCaseComponent />
1176+
<TitleCaseComponent />
11611177
```
11621178

1179+
This means that the TitleCase is the most universal _declaration convention_ and kebab-case is the most universal _usage convention_.
1180+
11631181
If your component isn't passed content via `slot` elements, you can even make it self-closing with a `/` after the name:
11641182

11651183
``` html

0 commit comments

Comments
 (0)