1)物業合夥人javascript
property_partnercss
2)數據可視化html
data_visualjava
1.images(存放圖片文件);數組
2.styles(存放css文件);瀏覽器
3.components(存放組件文件);bash
1)使用四個空格的soft tabs —這是保證代碼在各類環境下顯示一致的惟一方式。app
2)在屬性上,使用雙引號,不要使用單引號。框架
3)不要忽略可選的關閉標籤(例如,</li>和</body>)。編輯器
<!DOCTYPE html>
<html>
<head>
<title>Page title</title>
</head>
<body>
<img src="images/company-logo.png" alt="Company">
<h1 class="hello-world">Hello, world!</h1>
</body>
</html>複製代碼
1)頁面結構id命名
2)導航類id命名
導航:nav
3)功能類id命名
<!DOCTYPE html>
<html>
<head>
</head>
</html>複製代碼
<!-- External CSS -->
<link rel="stylesheet" href="code-guide.css">
<!-- In-document CSS -->
<style>
/* ... */
</style>
<!-- JavaScript -->
<script src="code-guide.js"></script>複製代碼
<!-- Not so great -->
<span class="avatar">
<img src="...">
</span>
<!-- Better -->
<img class="avatar" src="...">複製代碼
1)使用四個空格的soft tabs —這是保證代碼在各類環境下顯示一致的惟一方式。
2)爲了代碼的易讀性,在每一個聲明的左括號前增長一個空格。
3)儘量使用短的十六進制數值,例如使用#fff替代#ffffff。
4)不要爲0指明單位,好比使用margin: 0;而不是margin: 0px;。
/* Bad CSS */
.selector,.selector-secondary,.selector[type=text] {
padding: 15px;
margin: 0px 0px 15px;
background-color: rgba(0, 0, 0, 0.5);
box-shadow: 0 1px 2px #CCC, inset 0 1px 0 #FFFFFF
}
/* Good CSS */
.selector, .selector-secondary, .selector[type="text"] {
padding: 15px;
margin-bottom: 15px;
background-color: rgba(0,0,0,.5);
box-shadow: 0 1px 2px #ccc, inset 0 1px 0 #fff;
}複製代碼
1.若是多人協做,能夠考慮使用不一樣的前綴予以區分:內容fl-content;
2.命名技巧:
(1)
.red { color: red; }
.f60 { color: #f60; }
.ff8600 { color: #ff8600; }複製代碼
(2)字體大小,直接使用」font+字體大小」做爲名稱,如
.font12px { font-size: 12px; }
.font9pt {font-size: 9pt; }複製代碼
(3)對齊樣式,使用對齊目標的英文名稱,如
.left { float:left; }
.bottom { float:bottom; }複製代碼
(4)
.bar-news { }
.bar-product { }複製代碼
· padding
· margin
· font
· background
· border
· border-radius複製代碼
/* Bad example */
.element {
margin: 0 0 10px;
}
/* Good example */
.element {
margin-bottom: 10px;
}複製代碼
1)使用classes而不是通用元素標籤來優化渲染性能。
2)避免在常常出現的組件中使用一些屬性選擇器,(例如,[class^="..."])。瀏覽器性能會受到這些狀況的影響。
3)減小選擇器的長度,每一個組合選擇器選擇器的條目應該儘可能控制在3個之內。
4)只在必要的狀況下使用後代選擇器(例如,沒有使用帶前綴classes的狀況)。
/* Bad example */
span { ... }
.page-container #stream .stream-item .tweet .tweet-header .username { ... }
.avatar { ... }
/* Good example */
.avatar { ... }
.tweet-header .username { ... }
.tweet .avatar { ... }複製代碼
1)不容許有空的規則
2)去掉小數點前面的0
3)元素選擇器用小寫字母
4)儘可能少用'*'選擇器
5)選擇器不要超過4層
1)一概使用4個空格
2)語句以後一概以分號結束, 不能夠省略
3)單行長度,理論上不要超過80列,不過若是編輯器開啓soft wrap的話能夠不考慮單行長度
1)標準變量採用駝峯標識,使用let聲明。
2)常量採用大寫字母,下劃線鏈接的方式,使用const聲明。
3)構造函數,大寫第一個字母。
4)字符串使用單引號。
5)在函數做用域頂部聲明變量。
let thisIsMyName;
const MAX_COUNT = 10;
function Person(name) {
this.name = name
}複製代碼
*統一使用字面量聲明
// Bad
var team = new Team();
team.title = "AlloyTeam";
team.count = 25;
// Good semi colon 採用 Followed by space 的形式
var team = {
title: "AlloyTeam",
count: 25
};
// Bad
var colors = new Array("red", "green", "blue");
var numbers = new Array(1, 2, 3, 4);
// Good
var colors = [ "red", "green", "blue" ];
var numbers = [ 1, 2, 3, 4 ];複製代碼
1)雙斜線後,必須跟註釋內容保留一個空格;
2)可獨佔一行,前邊不準有空行,縮進與下一行代碼保持一致;
3)可位於一個代碼行的末尾,注意這裏的格式。
// Good
if (condition) {
// if you made it here, then all security checks passed
allowed();
}
var zhangsan = "zhangsan"; // 雙斜線距離分號四個空格,雙斜線後始終保留一個空格複製代碼
1)最少三行,格式以下;
2)前邊留空一行。
/*
*註釋內容與星標前保留一個空格
*/複製代碼
1) 永遠不要直接使用undefined進行變量判斷,使用typeof和字符串’undefined'對變量進行判斷。
// Bad
if(person === undefind) {
doSomething();
}
// Good
if(typeof person === 'undefined') {
doSomething();
doSomethingElse();
}複製代碼
if(condition) {
doSomething();
} else {
doSomethingElse();
}複製代碼
1)
2)使用快捷方式:
// Bad
if(name === '') {
doSomething();
}
// Good
if(name) {
doSomething();
doSomethingElse();
}
// Bad
if(name.length > 0) {
doSomething();
}
// Good
if(name.length) {
doSomething();
doSomethingElse();
}複製代碼
1)不要混用tab和空格。
2)對上下文this的引用只能使用’_this', 'that', ‘self’其中一個來命名。
3)行尾不要有空白字符。
4)不容許有空的代碼塊。
5)語句結束後必定要加分號;。
6)不但願其餘人修改的函數在名稱前加下劃線_。
7)花括號前必須有一個空格。
8)使用函數參數默認值。
// Bad
function test(arg) {
let val = arg || {}
}
// Good
function test(arg = {}) {
let val = arg
}複製代碼