随笔分类 -  javascript

摘要:原生JS forEach()和map()遍历 共同点: 1.都是循环遍历数组中的每一项。 2.forEach() 和 map() 里面每一次执行匿名函数都支持3个参数:数组中的当前项item,当前项的索引index,原始数组input。 3.匿名函数中的this都是指Window。 4.只能遍历数组 阅读全文
posted @ 2021-12-23 15:06 冯丙见 阅读(130) 评论(0) 推荐(0)
摘要:微信开发中经常遇到缓存问题 无法跳转 url后加上随机数 window.location.href = baseUrl + '?v='+(new Date().getTime()); window.location.href = baseUrl + '?v='+Math.random(); css, 阅读全文
posted @ 2021-12-21 12:51 冯丙见 阅读(1322) 评论(0) 推荐(0)
摘要:(function(){ document.ready = function(fn){ if(typeof fn !== 'function'){ throw 'Fn is not a function!'; } function completed() { document.removeEvent 阅读全文
posted @ 2021-12-21 12:49 冯丙见 阅读(50) 评论(0) 推荐(0)
摘要:在页面头部加载完时立即注入下面代码,注入完成后如若有xhr请求就可以监听到了 ;(function () { if ( typeof window.CustomEvent "function" ) return false; function CustomEvent ( event, params 阅读全文
posted @ 2021-12-20 09:03 冯丙见 阅读(1171) 评论(0) 推荐(0)
摘要:注意使用chrome.tabs.onUpdated.addListener需要在manifest.json声明tabs权限permissions: [‘tabs’]并且需要重新加载插件,如重新加载还是无法生效,请移除插件重新导入 /** * 监听tab页面变化(用于处理页面logo问题) */ ch 阅读全文
posted @ 2021-12-20 09:02 冯丙见 阅读(652) 评论(0) 推荐(0)
摘要:function createDom(htmlText) { let filterRegExp = [ // 转dom之前的正则处理 replace // [[], ], // 将script和link等替换掉 [['([a-zA-Z0-9\\-_]*?)="http', 'g'], 'zsl-$1 阅读全文
posted @ 2021-12-19 13:15 冯丙见 阅读(207) 评论(0) 推荐(0)