SASS的安装和学习成本都不高,所有的CSS语法在SASS中都是合法的(.scss)
- ruby & gem install sass
- same as CSS / LESS
SASS在混合这块和LESS的却别主要在于需要显性地使用@mixin
来定义混合,以及@include
来引入混合,这样的方式看似麻烦,但是实际上增加了代码的可读性,并且让混合的功能更加专一。
@mixin
## | |
# Host Database | |
# | |
# localhost is used to configure the loopback interface | |
# when the system is booting. Do not change this entry. | |
## | |
127.0.0.1 localhost | |
255.255.255.255 broadcasthost | |
::1 localhost | |
fe80::1%lo0 localhost |
const homePageLink = currentPage !== 'home' ? ( | |
<a | |
className="home-page-link" | |
target="_blank" | |
href="#home"> | |
Home | |
</a> | |
) : null; |
/* eslint-disable */ | |
import EventEmitter from 'wolfy87-eventemitter'; | |
import isFunction from 'lodash/isFunction'; | |
import isNumber from 'lodash/isNumber'; | |
import isString from 'lodash/isString'; | |
import isPlainObject from 'lodash/isPlainObject'; | |
function eventDelegate(dom, eventName, className, handler) { | |
dom.addEventListener(eventName, function (e) { | |
const target = e.target; |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<script src="http://www.parsecdn.com/js/parse-latest.js"></script> | |
<script src="https://adodson.com/hello.js/dist/hello.all.min.js"></script> | |
</head> | |
<body> |
!(function(){ | |
/** | |
* 判断当前JS环境 | |
*/ | |
var hasDefine = typeof define === 'function'; | |
var hasExports = typeof module !== 'undefined' && module.exports; | |
var Mod = function(){ | |
/* write your code */ |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>iframe - proxy</title> | |
</head> | |
<body> | |
<script> |
捕捉浏览器中的JS运行时错误,主要通过监听window.onerror来实现。但是对于不同的脚本执行方式以及不同的浏览器,能捕获到的信息会有区别。
window.onerror 讲接收3个参数:
msg
:错误描述,比如:a is not definedurl
:出错脚本所在的urllineNumber
:出错脚本的行数本文将对不同浏览器和不同的脚本执行方式进行测试,并总结这些区别。