js解决base64编码问题
发表于|更新于
|浏览量:
地利不如人和,武力不如文德。——恒宽
主要是在解析 JWT 时发现
1 | atob(base64) |
存在编码问题,我们如果想要将 base64 解码为 utf-8:
1 | function parseBase64ToJSON(base64) { |
然后就可以正确解析中文了
相关推荐
2021-06-21
wangEditor接入阿里云OSS
我唯一知道的就是自己无知。——苏格拉底最有学问和最有见识的人总是很谨慎的——卢梭 我们昨天接入了wangEditor富文本编辑器 今天我们试着将阿里云OSS集成进wangEditor 首先我们先使用vue在页面渲染结束后调用初始化wangEditor 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>OSS上传Demo</title> <link href="/css/elementUI.css" rel="stylesheet"> <script src="/js/jquery-3.5.1....
2022-03-11
Array.from
世界在音乐中得到了完整的再现和表达。它是各种艺术当中第一位的,帝王式的艺术,能够成为音乐那样,则是一切艺术的目的。——叔本华 继续还是js中Array的方法 这次说的方法是from:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/from 这个方法简单应用如下: 12345console.log(Array.from('foo'));// expected output: Array ["f", "o", "o"]console.log(Array.from([1, 2, 3], x => x + x));// expected output: Array [2, 4, 6] 我这里写个稍微复杂点的例子,随机生成文件名并排序 1[...new Set(Array.from(Array(200).fill('文件'),x=>x+String(...
2022-03-09
Array.prototype.fill()
新的方法和概念,常常比解决问题本身更重要。——华罗庚 我们在前端开发中,可以使用fill函数来快速构建数组 1Array(5).fill(1,1,4) 得到的是这样一个数组: 1[, 1, 1, 1, ] 这里参数fill(value,start,end)也是可以省略的 12345678910111213141516[1, 2, 3].fill(4); // [4, 4, 4][1, 2, 3].fill(4, 1); // [1, 4, 4][1, 2, 3].fill(4, 1, 2); // [1, 4, 3][1, 2, 3].fill(4, 1, 1); // [1, 2, 3][1, 2, 3].fill(4, 3, 3); // [1, 2, 3][1, 2, 3].fill(4, -3, -2); // [4, 2, 3][1, 2, 3].fill(4, NaN, NaN); // [1, 2, 3][1, 2, 3].fill(4, 3...
2024-03-09
订单确认按钮动画
志向不过是记忆的奴隶,生气勃勃地降生,但却很难成长。——莎士比亚 源码地址 https://codepen.io/aaroniker/details/eYOVrNa 非常炫酷的按钮效果,让人眼前一亮 主要都是靠css实现的 pug代码: 12345678910111213button(class='order') span(class='default') Complete Order span(class='success') Order Placed svg(viewbox='0 0 12 10') polyline(points='1.5 6 4.5 9 10.5 1') div(class='box') div(class='truck') div(class='back') div(class='front') div(class='...
2023-04-23
recordrtc
贫者因书而富,富者因书而贵。——王安石 分享一个JavaScript音频 + 视频 + 屏幕 + 画布(2D+ 3D动画)录制库:WebRTC https://recordrtc.org/ https://github.com/muaz-khan/RecordRTC demo:https://www.webrtc-experiment.com/RecordRTC/simple-demos/ 123456789101112let stream = await navigator.mediaDevices.getUserMedia({video: true, audio: true});let recorder = new RecordRTCPromisesHandler(stream, { type: 'video'});recorder.startRecording();const sleep = m => new Promise(r => setTimeout(r, m));await slee...
2023-08-16
vue-demi
事物都是互相妥协的。就是冰山也会时而消融,时而重新凝聚。——爱默生 分享一个vue库 https://github.com/vueuse/vue-demi 用来解决编写的代码在vue2和vue3之间的兼容问题 安装: 1npm i vue-demi 然后修改package.json,将vue 和@vue/composition-api添加到peerDependencies中 1234567891011121314151617{ "dependencies": { "vue-demi": "latest" }, "peerDependencies": { "@vue/composition-api": "^1.0.0-rc.1", "vue": "^2.0.0 || >=3.0.0" }, "peerDependenciesM...

阿超
我的名字叫阿超 年龄25岁 家在北京市 职业是软件开发 每天最晚也会在八点前回家 不抽烟 酒浅尝辄止 晚上十二点上床 保证睡足八个小时 睡前写一篇博客 再做二十分钟俯卧撑暖身 然后再睡觉 基本能熟睡到天亮 像婴儿一样不留下任何疲劳和压力 就这样迎来第二天的早晨 健康检查结果也显示我很正常 我想说明我是一个不论何时都追求内心平稳的人 不拘泥于胜负 不纠结于烦恼 不树立使我夜不能寐的敌人 这就是我在这社会的生活态度
Follow Me公告
This is my Blog