博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Notes about Vue Style Guide
阅读量:7125 次
发布时间:2019-06-28

本文共 3062 字,大约阅读时间需要 10 分钟。

A. Necessary

  1. Multiple-word for component’s name
  2. Data for component must be a function
  3. The definition of prop should be as detailed as possible (at least specified its type)
  4. Always use key with v-for
  5. Never use v-if & v-for to the same element (v-for has a higher priority than v-if when Vue deal with the directives)
  6. Set the scope for the component style, but use class rather than scoped feature
  7. Custom private attributes use the $_ prefix

B. Highlycommended

  1. Separate each component into files
  2. The filename of a single file component should always be either capitalized or always crosslinked
  3. The underlying components for which a particular style and convention are applied (that is, components that show classes, Illogical or stateless) should all begin with a specific prefix
  4. Components that are used only once per page should be named with “the” prefix
  5. Child components that are tightly coupled with the parent component (that means a component only makes sense in the context of a parent component) should be prefixed with the parent component name.
  6. Component names should begin with high-level (usually generic) words and end with descriptive modifiers.
  7. In single file components, string templates and components with no content in JSX should be self-closed-but never do so in DOM templates.
  8. For most projects, component names should always be PascalCase in single file components and string templates but always kebab-case in DOM templates
  9. The components name should be PascalCase in JS/JSX, but for applications that define global components only through Vue.component, kebab-case is recommended as an alternative
  10. Component names should tend to be full words instead of abbreviations
  11. When declaring prop, it should always be named with camelCase. But in templates & JSX you should use kebab-case
  12. Seprating multiple properties of an object by multiple rows that can improve the readability of the code
  13. Component templates should contain only simple expressions, and complex expressions should be refactored into computed properties or methods
  14. Divide complex computational attributes into as many simpler ones as possible
  15. Non-empty HTML attribute values should always be quoted
  16. Instruction abbreviation

C. Recommended

  1. There should be a uniform order of options for components/instances (default order recommended: )
  2. The properties of elements (including components) should have a uniform order (default order recommended: )
  3. Adding blank lines between multiple attributes can improve readability when components begin to be dense or difficult to read
  4. Single-file components should always keep the script template and style tags in the same order. And style should be at the end, because the other two tags must have at least one.

D. Be Attention (to use these as follow)

  1. Use v-if/v-else-if/v-else without using key
  2. Lots of element selectors appear in scoped
  3. Hidden parent-child component communication (use this.$parent or modify prop)
  4. Global State Management without Flux (manage global state by using this.$root or a global event bus)

All these referred to

转载地址:http://vpeel.baihongyu.com/

你可能感兴趣的文章
centOS 安装mp4box
查看>>
iOS中堆和栈的区别
查看>>
C语言之结构体
查看>>
linux globbing文件通配符
查看>>
Linux系统下查看命令属于哪个安装包
查看>>
C++拷贝构造函数详解
查看>>
Windows Server 2008 安装完活动目录后必要的检查
查看>>
一文为你详细讲解对象映射库【AutoMapper】所支持场景
查看>>
我的友情链接
查看>>
Mongod的复制
查看>>
Linux中find常见用法示例
查看>>
浅谈系统性能优化
查看>>
搭建Python环境与Python文件类型
查看>>
安装Tengine php mysql
查看>>
实战:mysql检查物理磁盘中的二进制日志文件是否有丢失
查看>>
检查mysql错误日志并发邮件通知
查看>>
【linux+C】通过几个实例温习指针
查看>>
华为刀片网卡漂移问题
查看>>
搜索专题:Balloons
查看>>
使用shell脚本采集系统cpu、内存、磁盘、网络等信息
查看>>