0
点赞
收藏
分享

微信扫一扫

Vue命名规范


1、组件名

官方推荐的组件名是 每个单词首字母大写(PascalCase) 或者 全小写用 - 连接(kebab-case) 。 在DOM中使用的时候, 改为全小写, 单词之间用 - 连接。单个字母也是大写。

Vue命名规范_前端


Vue命名规范_html_02

2、模板文件命名(小写或者驼峰命名法)

Vue命名规范_html_03

3、props

声明 prop的时候, 使用驼峰命名(myProps), 模板中使用的时候, 用 - 连接(my-props)

props: {
myProps: {}
}

<my-component :my-props="abc"></my-component>

4、自定义事件名

因为html对大小写不敏感,所以大写的都会被转为小写的。 所以推荐 都用 -连接来命名。

this.$emit('my-event');

<my-component @my-event="abc"></my-component>


举报

相关推荐

0 条评论