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
formatDate (timestamp, fmt) { | |
let date = new Date(timestamp); | |
if (/(y+)/.test(fmt)) { | |
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); | |
} | |
let o = { | |
'M+': date.getMonth() + 1, | |
'd+': date.getDate(), | |
'h+': date.getHours(), | |
'm+': date.getMinutes(), |
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 isHidden(el) { | |
return (el.offsetParent === null) | |
} | |
#### HTMLElement.offsetParent | |
HTMLElement.offsetParent 是一个只读属性,返回一个指向最近的(closest,指包含层级上的最近)包含该元素的定位元素。如果没有定位的元素,则 offsetParent 为最近的 table, table cell 或根元素(标准模式下为 html;quirks 模式下为 body)。 | |
当元素的 style.display 设置为 "none" 时,offsetParent 返回 null。 | |
offsetParent 很有用,因为 offsetTop 和 offsetLeft 都是相对于其内边距边界的。 | |
在 Webkit 中,如果元素为隐藏的(该元素或其祖先元素的 style.display 为 "none"),或者该元素的 style.position 被设为 "fixed",则该属性返回 null。 |
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.各浏览器下 scrollTop的差异: | |
IE6/7/8: | |
可以使用 document.documentElement.scrollTop; | |
IE9及以上: | |
可以使用window.pageYOffset或者document.documentElement.scrollTop | |
Safari: | |
safari: window.pageYOffset 与document.body.scrollTop都可以; | |
Firefox: | |
火狐等等相对标准些的浏览器就省心多了,直接用window.pageYOffset 或者 document.documentElement.scrollTop ; | |
Chrome: |
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
#### Node.parentNode | |
返回指定的节点在DOM树中的父节点. | |
对于下面的节点类型: Attr, Document, DocumentFragment, Entity, Notation,其parentNode属性返回null. | |
如果当前节点刚刚被建立,还没有被插入到DOM树中,则该节点的parentNode属性也返回null. | |
#### Node.parentElement | |
返回当前节点的父元素节点,如果该元素没有父节点,或者父节点不是一个元素节点.则 返回null. | |
DOM Level 4规范,mobile safari兼容性未知。 |
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
npm Error : EBUSY resource busy or locked | |
unlink 'F:\h5-front-end\v1\node_modules\node-sass\.git\objects\pack\pack-fd40e36b9fa5c01d631df175bf73f1aca32378fe.pack' | |
at Error (native) | |
可以npm cache clean | |
yarn cache clean |
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
获取元素作用域 | |
angular.element('html').scope() | |
调试$location 服务 | |
angular.element(document.querySelector('html')).injector().get('$location').search() | |
参考:https://lyfeyaj.com/2015/01/07/debugging-angularjs-apps-from-the-console/ |
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 httpInterceptor($httpProvider, $provide) { | |
$provide.factory('myHttpInterceptor', function($q, $location,$injector, $rootScope) { | |
//获取url参数 | |
var urlParms = (function() { | |
var searchStr = window.location.search; | |
var urlParms = searchStr ? window.jollyApp.getStringToJSON(searchStr) : $location.search(); //解析Url参数 | |
var env = window.jollyApp.ENV; | |
if (!urlParms['frm']) { | |
urlParms['frm'] = env.is_android ? 1 : env.is_ios ? 2 : 10; |
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
angularjs在初始化run或者config拦截器$httpProvider.interceptors里引入$scope会报错$scope Unknown provider: $scopeProvider | |
app.run([ | |
'httpService','$timeout','$rootScope','$scope', function(httpService,$timeout,$rootScope,$scope) { | |
$rootScope.tokenNew = 'test1'; | |
$timeout(function() { | |
$rootScope.$broadcast('getToken',$rootScope.tokenNew); | |
},2000) | |
}]); | |
只能用$rootScope, 比如用angular.element('body').scope()就会报undefined. |
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
Injecting $state (ui-router) into $http interceptor causes circular dependency | |
angularjs拦截器里面引入$state 报错 | |
循环引用 | |
可以使用$injector | |
参考:https://stackoverflow.com/questions/20230691/injecting-state-ui-router-into-http-interceptor-causes-circular-dependency | |
var interceptor = ['$location', '$q', '$injector', function($location, $q, $injector) { | |
function success(response) { | |
return response; | |
} |
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
网站: | |
http://devdocs.io/ | |
mac: | |
Dash,devdogs | |
Chrome App: | |
docdock |
NewerOlder