Skip to content

[vue] 说说组件的命名规范 #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
haizhilin2013 opened this issue Jun 22, 2019 · 5 comments
Open

[vue] 说说组件的命名规范 #441

haizhilin2013 opened this issue Jun 22, 2019 · 5 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

[vue] 说说组件的命名规范

@haizhilin2013 haizhilin2013 added the vue vue label Jun 22, 2019
@PanJiaChen
Copy link

风格指南

@maozhuo123
Copy link

大写开头

@zhanls
Copy link

zhanls commented Jul 4, 2019

举手🙋‍

官方样式指南里是这样写的:
“组件命名应当是多个单词的,但根目录下的App组件或Vue提供的如<transition>, <component>内置组件除外”
这样做可以避免跟现有的以及未来的 HTML 元素相冲突,因为所有的 HTML 元素名称都是单个单词的。

附:Style Guide — Vue.js

@GShJZhY
Copy link

GShJZhY commented Jul 29, 2019

定义组件名有两种方式:
1.kebab-case(短横线分隔命名),引用时必须也采用kebab-case;
2.PascalCase(首字母大写命名),引用时既可以采用PascalCase也可以使用kebab-case;
但在DOM中使用只有kebab-case是有效的

@radio-qq
Copy link

组件名:大驼峰
调用组件时:小驼峰且-分隔
如:命名:MyComponent,调用:my-component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

6 participants