随笔分类 -  js

摘要:var element = new Image(); Object.defineProperty(element, "id", { get: function () { debugger; }, }); requestAnimationFrame(function check() { console 阅读全文
posted @ 2020-10-12 15:12 Ajanuw 阅读(1219) 评论(0) 推荐(0)
摘要:使用创建style的方式 btn.addEventListener("click", async () => { const ns = document.createElement("style"); ns.textContent = ` button { color: red; } `; docu 阅读全文
posted @ 2020-10-11 12:16 Ajanuw 阅读(198) 评论(0) 推荐(0)
摘要:在表单提交前修改数据,此事件在submit之后 f1.addEventListener("formdata", (e) => { e.formData.append("phone", "xxx"); }) 阅读全文
posted @ 2020-10-11 11:39 Ajanuw 阅读(543) 评论(0) 推荐(0)
摘要:btn.addEventListener("click", async () => { try { const state = await Notification.requestPermission(); if (state !== "granted") { // Need to request 阅读全文
posted @ 2020-10-11 11:07 Ajanuw 阅读(673) 评论(0) 推荐(0)
摘要:let lock; btn.addEventListener("click", async () => { try { if (lock) { lock.release(); return; } lock = await navigator.wakeLock.request("screen"); l 阅读全文
posted @ 2020-10-11 10:39 Ajanuw 阅读(630) 评论(0) 推荐(0)
摘要:选择文件,获取文件句柄 btn.addEventListener("click", async (e) => { try { const hFiles = await window.showOpenFilePicker({ types: [ { description: "文本文件", accept 阅读全文
posted @ 2020-10-09 20:14 Ajanuw 阅读(2379) 评论(0) 推荐(1)
摘要:function hookSend(hook) { if (!XMLHttpRequest.prototype._oldSend) XMLHttpRequest.prototype._oldSend = XMLHttpRequest.prototype.send; XMLHttpRequest.pr 阅读全文
posted @ 2020-10-06 22:59 Ajanuw 阅读(457) 评论(0) 推荐(0)
摘要:原文 定义掩码 const mask0 = parseInt("00000001", 2); const mask1 = parseInt("00000010", 2); const mask2 = parseInt("00000100", 2); const mask3 = parseInt("0 阅读全文
posted @ 2020-08-26 11:03 Ajanuw 阅读(618) 评论(0) 推荐(0)
摘要:for (let i = 0; i < 3; i++) { console.log(i); } let i = 0; for (;;) { if (!(i < 3)) { break; } console.log(i); i++; } 添加label end: for (let i = 0; i < 阅读全文
posted @ 2020-08-23 12:37 Ajanuw 阅读(143) 评论(0) 推荐(0)
摘要:https://www.npmjs.com/package/xlsx 安装依赖 npm install xlsx Example import * as XLSX from "xlsx"; export const Sheet1 = "Sheet1"; export const Sheet2 = " 阅读全文
posted @ 2020-07-01 12:56 Ajanuw 阅读(497) 评论(0) 推荐(0)
摘要:<button id="btn1">长按触发</button> <button id="btn2">长按触发2</button> interface IOpt { el: HTMLElement; listener: EventListener; options?: boolean | AddEve 阅读全文
posted @ 2020-04-21 10:53 Ajanuw 阅读(2254) 评论(0) 推荐(1)
摘要:function co<T>(fn: () => Generator<any, any, any>): Promise<T> { const g: Generator = fn(); return new Promise((resolve, reject) => { const r = g.next 阅读全文
posted @ 2020-04-11 10:17 Ajanuw 阅读(175) 评论(0) 推荐(0)
摘要:let _subscriber: any; function autorun(subscriber: Function) { _subscriber = subscriber; _subscriber(); _subscriber = null; } class Observer { #list: 阅读全文
posted @ 2020-04-04 18:28 Ajanuw 阅读(433) 评论(0) 推荐(1)
摘要:在edge上有效 使用 "video.js" 阅读全文
posted @ 2020-03-27 23:16 Ajanuw 阅读(3745) 评论(0) 推荐(0)
摘要:灵感来自此博客和此库 index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scal 阅读全文
posted @ 2020-03-18 14:06 Ajanuw 阅读(374) 评论(0) 推荐(0)
摘要:1: 使用reject function hello() { let _res, _rej: any; const promise = new Promise((res, rej) => { _res = res; _rej = rej; setTimeout(() => { res("hello 阅读全文
posted @ 2020-03-18 11:17 Ajanuw 阅读(3618) 评论(0) 推荐(1)
摘要:"mdn" ts const rx_one = /^[\],:{}\s] $/; const rx_two = /\\(?:["\\\/bfnrt]|u[0 9a fA F]{4})/g; // 匹配合法json符号 // "asd" or 1.23 or 1.3e4 or 1.3e 4 or 1. 阅读全文
posted @ 2020-02-27 14:48 Ajanuw 阅读(243) 评论(0) 推荐(0)
摘要:"astexplorer" "babel types" code to ast js const { parse } = babel; const code = ` for (let k in ${data}) { let ${path.__cxt} = _setCxt(k, ${data}); } 阅读全文
posted @ 2020-02-08 17:28 Ajanuw 阅读(1275) 评论(0) 推荐(0)
摘要:反应 行动 阅读全文
posted @ 2020-01-11 15:54 Ajanuw 阅读(197) 评论(0) 推荐(0)
摘要:myEval export const evalExp = /[!\&\|\+\-\*\%=\/<\>\^\(\)\~\:\?\;]/g; export function myEval(originString: string, context: any) { if (!context) retur 阅读全文
posted @ 2019-12-20 16:48 Ajanuw 阅读(1959) 评论(0) 推荐(1)