1.css禁用鼠標事件
.disabled { pointer-events: none; cursor: default; opacity: 0.6; }
2.get/post的理解和他們之間的區別
http
超文本傳輸協議(HTTP)的設計目的是保證客戶機與服務器之間的通訊。 HTTP 的工做方式是客戶機與服務器之間的請求-應答協議。 web 瀏覽器多是客戶端,而計算機上的網絡應用程序也可能做爲服務器端。
http方法:
HEAD: 與 GET 相同,但只返回 HTTP 報頭,不返回文檔主體 PUT: 上傳指定的 URI 表示 DELETE: 刪除指定資源 OPTIONS: 返回服務器支持的 HTTP 方法 CONNECT: 把請求鏈接轉換到透明的 TCP/IP 通道 POST: 向指定的資源提交要被處理的數據
// 查詢字符串(名稱/值對)是在 POST 請求的 HTTP 消息主體中發送的 POST /test/demo_form.asp HTTP/1.1 Host: w3schools.com name1=value1&name2=value2
GET: 從指定的資源請求數據
GET和POST的區別
GET 請求可被緩存 GET 請求保留在瀏覽器歷史記錄中 GET 請求可被收藏爲書籤 GET 請求不該在處理敏感數據時使用 GET 請求有長度限制(2048字符),IE和Safari瀏覽器限制2k;Opera限制4k;Firefox,Chrome限制8k GET 請求只應當用於取回數據
POST 請求不會被緩存 POST 請求不會保留在瀏覽器歷史記錄中 POST 不能被收藏爲書籤 POST 請求對數據長度沒有要求
3.實現條紋網格的方式
nth-child(even/odd)
// odd表示基數,此時選中基數行的樣式,even表示偶數行 .row:nth-child(odd){ background: #eee; }
nth-of-type(odd)
.row:nth-of-type(odd){ background: #eee; }
漸變實現linear-gradient
.stripe-bg{ padding: .5em; line-height: 1.5em; background: beige; background-size: auto 3em; background-origin: content-box; background-image: linear-gradient(rgba(0,0,0,.2) 50%, transparent 0); }
4.js求平面兩點之間的距離
// 數據能夠以數組方式存儲,也能夠是對象方式 let a = {x:'6', y:10}, b = {x: 8, y: 20}; function distant(a,b){ let dx = Number(a.x) - Number(b.x) let dy = Number(a.y) - Number(b.y) return Math.pow(dx*dx + dy*dy, .5) }
5.css禁止用戶選擇
body{ -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
6.數組去重
// indexOf實現 var array = [1, 1, '1']; function unique(array) { var res = []; for (var i = 0, len = array.length; i < len; i++) { var current = array[i]; if (res.indexOf(current) === -1) { res.push(current) } } return res; } console.log(unique(array)); // 排序後去重 var array = [1, 1, '1']; function unique(array) { var res = []; var sortedArray = array.concat().sort(); var seen; for (var i = 0, len = sortedArray.length; i < len; i++) { // 若是是第一個元素或者相鄰的元素不相同 if (!i || seen !== sortedArray[i]) { res.push(sortedArray[i]) } seen = sortedArray[i]; } return res; } console.log(unique(array)); // filter實現 var array = [1, 2, 1, 1, '1']; function unique(array) { var res = array.filter(function(item, index, array){ return array.indexOf(item) === index; }) return res; } console.log(unique(array)); // 排序去重 var array = [