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 ...
随机推荐
- Communication with each role instance in Azure
Use WCF Communication with role instance in azure 1)In worker role build WCF Service public overrid ...
- VUE学习(一)
1.搭建vue环境 2.了解 v-on 事件监听,常常跟事件(click,mousemove,change等鼠标或者手势事件)在一起,eg:v-on:click,语法糖——:(冒号) 需要在meth ...
- Qt 学习之路 2(47):视图选择
Qt 学习之路 2(47):视图选择 豆子 2013年3月28日 Qt 学习之路 2 34条评论 选择是视图中常用的一个操作.在列表.树或者表格中,通过鼠标点击可以选中某一项,被选中项会变成高亮或者反 ...
- Octave安装符号工具箱
1.国内访问Octave的代码包不稳定,可以访问网址http://sourceforge.mirrorservice.org/o/oc/octave/Octave%20Forge%20Packages ...
- notepad++配置编译运行java
点击插件->Plugin Manager->show plugin manager : 选择NppExec,选择install,就将这个插件下载下来了. 这个时候会重启notepad++: ...
- 1128 N Queens Puzzle (20 分)
The "eight queens puzzle" is the problem of placing eight chess queens on an 8 chessboard ...
- scrapy框架的另一种分页处理以及mongodb的持久化储存以及from_crawler类方法的使用
一.scrapy框架处理 1.分页处理 以爬取亚马逊为例 爬虫文件.py # -*- coding: utf-8 -*- import scrapy from Amazon.items import ...
- 剑指offer5.1——O(n)的复杂度合并两个有序数组
#include"iostream" #include"stdio.h" using namespace std; int* ArrayMerge(int *a ...
- PIE SDK矢量数据简单渲染
1. 功能简介 PIE SDK对数据的符号化分为矢量数据渲染和栅格数据渲染两大类. 目前PIE SDK中针对矢量数据渲染包括简单渲染.唯一值渲染.分级渲染.自定义渲染:针对栅格数据渲染包括拉伸渲染.R ...
- PIE SDK位深转换
1.算法功能简介 位深转换功能是一种用于更改一个给定输入文件数据范围的灵活方法.可以完全控制输入和输出直方图,以及输出数据类型(字节型.整型.浮点型等). PIE支持算法功能的执行,下面对位深转换 ...