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/components.md
+24-6Lines changed: 24 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1128,7 +1128,7 @@ Note that when used as a route component in `vue-router`, these properties will
1128
1128
1129
1129
### Component Naming Conventions
1130
1130
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.
1132
1132
1133
1133
```js
1134
1134
// in a component definition
@@ -1151,15 +1151,33 @@ Within HTML templates though, you have to use the kebab-case equivalents:
1151
1151
<title-cased-component></title-cased-component>
1152
1152
```
1153
1153
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
+
```
1155
1167
1156
1168
```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 />
1161
1177
```
1162
1178
1179
+
This means that the TitleCase is the most universal _declaration convention_ and kebab-case is the most universal _usage convention_.
1180
+
1163
1181
If your component isn't passed content via `slot` elements, you can even make it self-closing with a `/` after the name:
0 commit comments