34
2022-03-04 14:05:34 34阅读 0喜欢
console.log('%c Hi everyone!', 'color: #1c87c9; font-size: 18px');
console.log('%c Style 1! %c Style 2!',
  'color: #1c87c9; background: #ccc; font-size: 20px;', 
  'color: #8ebf42; background: # 666; font - size: 20 px;'
);
6
2022-03-04 13:46:49 6阅读 0喜欢
let number = 4579
let hexStr = number.toString(16)
console.log(hexStr)  // 11e3

let hexStr2 = '11e3'
let number2 = parseInt(hexStr2, 16)
console.log(number2)  // 4579
944访问人次
Camila Waz 2022-03-07 09:31:16
11
2022-03-04 13:37:21 11阅读 0喜欢
let str = "Hello People"
let encodedString = btoa(str)
console.log(encodedString) // "SGVsbG8gUGVvcGxl"

let dec = atob(encodedString)
console.log(dec) // "Hello People"
21
2022-03-04 11:09:33 21阅读 0喜欢
canvas.toBlob(function(blob) {
  // blob ready, download it
  let link = document.createElement('a');
  link.download = 'example';

  link.href = URL.createObjectURL(blob);
  link.click();

  // delete the internal blob reference, to let the browser clear memory from it
  URL.revokeObjectURL(link.href);
}, 'image/jpg');
34
2022-03-04 10:29:11 34阅读 0喜欢
<a download="hello.txt" href='#' id="link">Download</a>

<script>
   let blob = new Blob(["Hello, world!"], {type: 'text/plain'}); 
   link.href = URL.createObjectURL(blob);
</script>
78