Notes about Vue Style Guide
- Multiple-word for component’s name
- Data for component must be a function
- The definition of prop should be as detailed as possible (at least specified its type)
- Always use key with v-for
- 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)
- Set the scope for the component style, but use class rather than scoped feature
- Custom private attributes use the $_ prefix
- Separate each component into files
- The filename of a single file component should always be either capitalized or always crosslinked
- 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
- Components that are used only once per page should be named with “the” prefix
- 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.
- Component names should begin with high-level (usually generic) words and end with descriptive modifiers.
- In single file components, string templates and components with no content in JSX should be self-closed-but never do so in DOM templates.
- For most projects, component names should always be PascalCase in single file components and string templates but always kebab-case in DOM templates
- 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
- Component names should tend to be full words instead of abbreviations
- When declaring prop, it should always be named with camelCase. But in templates & JSX you should use kebab-case
- Seprating multiple properties of an object by multiple rows that can improve the readability of the code
- Component templates should contain only simple expressions, and complex expressions should be refactored into computed properties or methods
- Divide complex computational attributes into as many simpler ones as possible
- Non-empty HTML attribute values should always be quoted
- Instruction abbreviation
- There should be a uniform order of options for components/instances (default order recommended:https://cn.vuejs.org/v2/style-guide/#%E7%BB%84%E4%BB%B6-%E5%AE%9E%E4%BE%8B%E7%9A%84%E9%80%89%E9%A1%B9%E7%9A%84%E9%A1%BA%E5%BA%8F-%E6%8E%A8%E8%8D%90)
- The properties of elements (including components) should have a uniform order (default order recommended: https://cn.vuejs.org/v2/style-guide/#%E5%85%83%E7%B4%A0%E7%89%B9%E6%80%A7%E7%9A%84%E9%A1%BA%E5%BA%8F-%E6%8E%A8%E8%8D%90)
- Adding blank lines between multiple attributes can improve readability when components begin to be dense or difficult to read
- 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.
- Use v-if/v-else-if/v-else without using key
- A large number of element selectors appear in scoped
- Hidden parent-child component communication (use this.$parent or modify prop)
- Global State Management without Flux (manage global state by using this.$root or a global event bus)
All these referred to https://cn.vuejs.org/v2/style-guide/
Notes about Vue Style Guide的更多相关文章
- Google C++ Style Guide
Background C++ is one of the main development languages used by many of Google's open-source project ...
- python coding style guide 的高速落地实践
python coding style guide 的高速落地实践 机器和人各有所长,如coding style检查这样的可自己主动化的工作理应交给机器去完毕,故发此文帮助你在几分钟内实现coding ...
- python coding style guide 的快速落地实践——业内python 编码风格就pep8和谷歌可以认作标准
python coding style guide 的快速落地实践 机器和人各有所长,如coding style检查这种可自动化的工作理应交给机器去完成,故发此文帮助你在几分钟内实现coding st ...
- 与你相遇好幸运,The Moe Node.js Code Style Guide
The Moe Node.js Code Style Guide By 一个最萌的开发者 @2016.9.21 >>代码是人来阅读的,格式规范的代码是对编程人员最好的礼物 :) > ...
- 使用tdcss.js轻松制作自己的style guide
http://jakobloekke.github.io/tdcss.js/ 在前端开发中,如果能够有一个style guide对于设计来说就显得专业稳定,一致性.在上述链接中,有一个tdcss.js ...
- Google C++ Style Guide在C++11普及后的变化
转 http://www.cnblogs.com/chen3feng/p/5972967.html?from=timeline&isappinstalled=0&lwfrom=user ...
- Common Lisp Style Guide - Ariel Networks Labs
Common Lisp Style Guide - Ariel Networks Labs Common Lisp Style Guide
- 一张图总结Google C++编程规范(Google C++ Style Guide)
Google C++ Style Guide是一份不错的C++编码指南,我制作了一张比較全面的说明图,能够在短时间内高速掌握规范的重点内容.只是规范毕竟是人定的,记得活学活用.看图前别忘了阅读以下三条 ...
- Airbnb JavaScript Style Guide
Airbnb JavaScript Style Guide() { 用更合理的方式写 JavaScript ES5 的编码规范请查看版本一,版本二. 翻译自 Airbnb JavaScrip ...
随机推荐
- [Swift实际操作]八、实用进阶-(10)使用Swift创建一个二叉树BinaryTreeNode
1.二叉树的特点: (1).每个节点最多有两个子树(2).左子树和右子树是有顺序的,次序不能颠倒(3).即使某节点只有一个子树,也要区分左右子树 2.二叉查找树(Binary Search Tree) ...
- 帝国cms刷新内容页提示.phome_ecms_news_data_' doesn't exist
帝国cms后台刷新提示.phome_ecms_news_data_' doesn't exist解决方法: 刷新所有信息内容页面时提示“Table '*.phome_ecms_article_data ...
- 将form转为ajax提交的js代码
参考网络代码基础上进行修改,调试通过. 在html中插入下面的代码: 函数ajaxSubmit是submit的ajax形式. 注意:这里面使用到了jquery库 //<!--将form中的值转换 ...
- css实现正方形div的3种方式
网上百度了几种可以按照百分比画方框的方法 1.CSS3 vw 单位 1vw = 1% viewport width <div class="vw">hello,view ...
- 洛谷 P1546 最短网络 Agri-Net(最小生成树)
嗯... 题目链接:https://www.luogu.org/problemnew/show/P1546 首先不难看出这道题的思想是用了最小生成树,但是这道题有难点: 1.读题读不明白 2.不会读入 ...
- tornado 06 数据库—ORM—SQLAlchemy——基本内容及操作
tornado 06 数据库—ORM—SQLAlchemy——基本内容及操作 一. ORM #在服务器后台,数据是要储存在数据库的,但是如果项目在开发和部署的时候,是使用的不同的数据库,该怎么办?是不 ...
- Vue keep-alive 组件.
如果不用 webpack , 那么 name 就是 vue.component(name) 这个 name 就是 export default { name:"index"} 的那 ...
- myeclipse启动后,卡在loading workbench界面
今天在修改svn的配置文件的时候,电脑重启了几次,然后myeclipse启动的时候就一直卡在loading workbeach动不了了. 重启了几次也不行,后来查的百度,找到的解决方法如下: 找到my ...
- C# 关于时区的操作
有关时区自动更新的 在注册表以下路径,start键值3,4表示自动/不自动更新 计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\tza ...
- Android so 库按需打包
Fresco 大部分的代码是由Java写的,但是里面也有很多C++的代码.C++代码必须根据Android 设备的CPU类型(通常称为”ABIs”)进行编译.目前Fresco支持五种 ABI: arm ...