This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'), | |
sass = require('gulp-sass'), | |
rename = require('gulp-rename'), | |
uglify = require('gulp-uglify'), | |
cssnano = require('gulp-cssnano'), | |
concat = require('gulp-concat'), | |
imagemin = require('gulp-imagemin'), | |
autoprefixer = require('gulp-autoprefixer'), | |
sprite = require('gulp.spritesmith'), | |
sourcemaps = require('gulp-sourcemaps'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(doc, win) { | |
var docEle = doc.documentElement, | |
evt = "onorientationchange" in window ? "orientationchange" : "resize", | |
setBaseFontSize = function() { | |
var width = docEle.clientWidth; | |
// 基于320px宽的设计稿,对应100px的基准字体 | |
width && ( docEle.style.fontSize = 100 / 320 * width + "px" ); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a; | |
var b = a * 0; // -> NaN | |
// NaN == NaN -> false | |
// NaN === NaN -> false | |
// b == b -> false | |
if (b == b) { | |
console.log(b * 2 + "2" - 0 + 4); | |
} else { | |
// 通过 - 号将字符串拼接转换为算术运算 | |
console.log(!b * 2 + "2" - 0 + 4); // -> 26 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ( var d = 0; d < 3; d++ ) { | |
// 定时器异步执行,它执行时循环已经结束,d的值为3 | |
setTimeout(function(){ | |
console.log(d); | |
}, 100); | |
// console记录3次 | |
// -> 3 | |
// -> 3 | |
// -> 3 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var outer=null; | |
var fn=function(){ | |
var a=1; | |
// 闭包可以访问函数内部的变量 | |
outer=function(){ | |
a++; | |
console.log(a); | |
} | |
} | |
// 调用fn后,outer有可能用到fn中定义的a,所以a不会被清除,a的生命周期得以延长 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@charset "utf-8"; | |
/* ============================= 重置样式 ===================================*/ | |
/* 清除内外边距 */ | |
body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, /* structural elements 结构元素 */ | |
dl, dt, dd, ul, ol, li, /* list elements 列表元素 */ | |
pre, /* text formatting elements 文本格式元素 */ | |
fieldset, legend, button, input, textarea, /* form elements 表单元素 */ | |
th, td { /* table elements 表格元素 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title></title> | |
<style> | |
.table { | |
width: 800px; | |
height: 600px; | |
background-color: #fafafa; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. | |
function unShowPopup() { | |
$(document).on('click', function(ev) { | |
var $target = $(ev.target); | |
// 当查找到顶部时还找不到指定的类名,则循环结束 | |
while ($target.length > 0) { | |
// 当找到了指定类名时,则跳出函数,即不隐藏拥有该类名的元素 | |
if ($target.hasClass('dataform')) { | |
console.log(1); | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function minComMulti() { | |
var args = [].slice.call(arguments); | |
var len = args.length; | |
if (len < 1) return; | |
if (len === 1) return args[0]; | |
if (len === 2) { | |
// minTwoMulti(); | |
var max = Math.max.apply(Math, args); | |
var min = Math.min.apply(Math, args); | |
for (var i = 1;; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// common divisor | |
function maxComDivisor() { | |
var args = [].slice.call(arguments); | |
var len = args.length; | |
function maxTwoDivi() { | |
// var args = [].slice.call(arguments); | |
// console.log(args); | |
var max = Math.max.apply(Math, arguments); | |
var min = Math.min.apply(Math, arguments); | |
if (max % min === 0) { |
OlderNewer