8000 provide more details in template component name description · vuejs-jp-bot/jp.vuejs.org@54b979e · GitHub
[go: up one dir, main page]

Skip to content

Commit 54b979e

Browse files
chrisvfritzvuejs-jp-bot
authored andcommitted
provide more details in template component name description
1 parent 1bb2805 commit 54b979e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/v2/style-guide/index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,13 @@ Unfortunately, HTML doesn't allow custom elements to be self-closing - only [off
857857

858858
**Component names should always be PascalCase in [single-file components](single-file-components.html) and string templates - but kebab-case in DOM templates.**
859859

860-
PascalCase in templates improves readability, because it's easier to tell at a glance what's an element and what's a component. Unfortunately, PascalCase is invalid for a custom element in HTML, so a DOM template must still use kebab-case.
860+
PascalCase has a few advantages over kebab-case:
861+
862+
- Editors can autocomplete component names in templates, because PascalCase is also used in JavaScript.
863+
- `<MyComponent>` is more visually distinct from a single-word HTML element than `<my-component>`, because there are two character differences (the two capitals), rather than just one (a hyphen).
864+
- If you use any non-Vue custom elements in your templates, such as a web component, PascalCase ensures that your Vue components remain distinctly visible.
865+
866+
Unfortunately, due to HTML's case insensitivity, DOM templates must still use kebab-case.
861867

862868
{% raw %}<div class="style-example example-bad">{% endraw %}
863869
#### Bad

0 commit comments

Comments
 (0)
0