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 ...
随机推荐
- Centos查看端口占用令
Centos查看端口占用情况命令,比如查看80端口占用情况使用如下命令: lsof -i tcp:80 列出所有端口 netstat -ntlp 1.开启端口(以80端口为例) 方法一: /sbin/ ...
- JavaScript学习笔记——2.数据类型与类型转换
数据类型 JS中一共分成六种数据类型 1- String 字符串 2- Number 数值 3- Boolean 布尔值 4- Null 空值 5- Undefined 未定义 6- Object 对 ...
- centos配置免密登录
一.准备工作 1.先准备两台centos机器.例如:192.168.1.100和192.168.1.101两台机器,配置101免密登录100 2.默认centos会自带ssh和stfp,机器未安装,请 ...
- 【算法笔记】B1032 挖掘机技术哪家强
1032 挖掘机技术哪家强 (20 分) 为了用事实说明挖掘机技术到底哪家强,PAT 组织了一场挖掘机技能大赛.现请你根据比赛结果统计出技术最强的那个学校. 输入格式: 输入在第 1 行给出不超过 1 ...
- [转] CSS3垂直手风琴折叠菜单
[From] http://www.html5tricks.com/css3-ver-accordion-menu.html 之前我们已经分享过很多关于手风琴菜单了,有水平方向的,也有垂直方向的.今天 ...
- poj3176
一.题意:给定一些数,成三角形排列.从上往下走,每个数只能往它相邻的两个数走,一直走到底端得到一条线路.这条线路上的数的和最大是多少 二.思路:简单的动态规划.dp[i+1][j+1]:=以第i+1行 ...
- linux系统优化基础
linux系统优化基础 tags: linux 优化 kingle---### 1, 查看centos版本:cat etc/redhat-release 看看centos架构信息:uname -m 查 ...
- 第十六章:自定义push notification sound
前面一节已经讲过如何在ionic中集成jpush,这样我们的hybrid app在部署到ios或者android上面的时候,就可以接收通知了.如果不满足系统自带的声音,可以通过一些方式来播放自定义的通 ...
- TOJ 1258 Very Simple Counting
Description Let f(n) be the number of factors of integer n. Your task is to count the number of i(1 ...
- 121、Django rest framework入门使用
框架介绍 为你的django平台通过model生成对应的restfull api,并可以通过对应的http接口来进行 post .get.put.delete等操作.本文是也并非入门级别,不会带你去了 ...