随笔分类 - javascript
摘要:<script> let bt = document.querySelector("input"); let mydiv = document.querySelector("div"); let xhr = "null"; // fetch为全局对象的方法,非js库 bt.onclick = fun
阅读全文
摘要:<script> let bt = document.querySelector("input"); let mydiv = document.querySelector("div"); let xhr = "null"; bt.onclick = function () { xhr = new X
阅读全文
摘要:请求端 <body> <div> hello world</div> <input type="button" value="ajax"> </body> <style> div { width: 200px; height: 300px; border: aquamarine 1px solid;
阅读全文
摘要:定义 export default { uname: "li", hello: function () { console.log("hello"); } } 引入 <body> <script type="module"> import * as m from "./app.js" import
阅读全文
摘要:问题 Access to script at 'file:///C:/Users/limakilo0000/OneDrive/limakilo2020.github.io/app.js' from origin 'null' has been blocked by CORS policy: Cros
阅读全文
摘要:基本用法 let p = new Promise(function (resovle, reject) { let data = "yes or not"; // resovle(data); reject(data); //调用then第二个方法 }) p.then(function (value
阅读全文
摘要:// 数组遍历方式 let arr = ["a", "b"]; //forEach arr.forEach((a, b) => { console.log(b, ":", a); }) //for of for (const el of arr) { console.log(el, " indexo
阅读全文
摘要:jsonp:通过请求script资源 html代码: <body> <div> hello world</div> </body> <style></style> <script> function hello() { document.querySelector("div").style.back
阅读全文
摘要:<script> function Phone(uname) { // 此方法每个实例共享 Phone.prototype.f = function() { console.log("prototype"); } this.name = uname; this.fun = function() {
阅读全文
摘要://实时显示鼠标在页面中的位置 var inp = document.querySelector("div"); document.addEventListener("mousemove", function (e) { inp.style.position = "absolute"; inp.st
阅读全文
摘要:// 阻止右键出现菜单 document.addEventListener("contextmenu", function (e) { e.preventDefault(); }) // 阻止文字被选中 document.addEventListener("selectstart", functio
阅读全文
摘要:function two(e) { alert("two"); console.log(e); 阻止默认行为 e.preventDefault(); 阻止向上冒泡 e.stopPropagation() } var div2 = document.querySelector("a"); div2.a
阅读全文

浙公网安备 33010602011771号