错误信息获得三点:
- 错误发生在哪一行
- 什么类型的错误
- 错误信息是什么
错误类型:
- SyntaxError: 语法错误
- ReferenceError: 使用了不存在的变量
// 防抖 | |
const debounce = (fn, wait = 50) => { | |
let timer = null | |
return function (...args) { | |
clearTimeout(timer) | |
timer = setTimeout(() => { | |
fn.apply(this, args) | |
}, wait) | |
} | |
} |
<input type="file" id="flie" name="file"/> | |
<script> | |
const file = document.getElementById('flie') | |
file.onchange = function(e) { | |
const f = this.files[0] | |
const formData = new FormData() | |
formData.append("file", f) |
<span id="pwd_spn" class="password-span">Test</span> | |
<button id="cp_btn">Copy</button> | |
<script> | |
document.getElementById("cp_btn").addEventListener("click", copy_password); | |
function copy_password() { | |
var copyText = document.getElementById("pwd_spn"); | |
var textArea = document.createElement("textarea"); | |
textArea.value = copyText.textContent; |
const fs = require('fs') | |
const path = './Photoshop 人物肖像全面修饰实例教程' | |
const replaceStr = '【doyoudo全部课程都有 微信sgyx1120】' | |
try { | |
const files = fs.readdirSync(path) | |
files.map(item => { | |
const oldPath = `${path}/${item}` | |
const newPath = `${path}/${item.replace(replaceStr, '')}` | |
fs.rename(oldPath, newPath, err => { throw err}) |
错误信息获得三点:
错误类型:
var funDownload = function (content, filename) { | |
// 创建隐藏的可下载链接 | |
var eleLink = document.createElement('a'); | |
eleLink.download = filename; | |
eleLink.style.display = 'none'; | |
// 字符内容转变成blob地址 | |
var blob = new Blob([JSON.stringify(content)]); | |
eleLink.href = URL.createObjectURL(blob); | |
// 触发点击 | |
document.body.appendChild(eleLink); |
html { | |
font-size: -webkit-calc(100vw/7.5); | |
font-size: calc(100vw/7.5); | |
} |
/** | |
* @description The method will send a Ajax request with Promise. | |
* @param {String} url | |
* @return {Promise} | |
*/ | |
function get(url) { | |
return new Promise((resolve, reject) => { | |
let req = new XMLHttpRequest() |