Files
ebiz-h5/vue编码规范.md
邓晓坤 ff8a261f79 提交
2019-09-12 16:22:38 +08:00

22 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
- Vue文件命名 大驼峰式命名法即每个单词的首字母大写CamelCase.vue2-3个单词用具体意义不要过于简写。
- 定义变量使用let 定义常量使用const使用exportimport 模块化。
- 基于模块方式开发每个Vue文件等同于一个模块模块应该专注于解决单一问题是独立的可服用的。
- 行内表达式尽量简化,太复杂了不宜阅读和维护,可以考虑使用 method 或是 computed 属性来替代其功能;如获取年:(new Date()).getFullYear()不要写在行内使用computed来实现。
- 组件props尽量使用原始类型字符串、数字、布尔值这样清晰直观便于理解。尽量避免使用复杂的对象。使用prop验证代码更严谨。具体请参考prop验证
- 使用ES6的箭头函数这样就不用切换上下文不用编写类似let self = this这样的代码。
- 组件自定义事件命名使用中横岗,对应组件外的一组意义操作。
- 避免使用this.$parent
- 谨慎使用this.$refs
- 样式作用域空间:<style scoped></style>
- 代码校验:[ESLint](https://eslint.org/)
- 待完善……