let enc = new TextDecoder('utf-8')
let item = JSON.parse(enc.decode(new Uint8Array(res.data))) //转化成json对象
console.log(item)
// 节流
const on = Vue.prototype.$on
Vue.prototype.$on = function (event, func) {
let previous = 0
let newFunc = func
if (event === 'click') {
newFunc = function () {
const now = new Date().getTime()
if (previous + 1000 <= now) {
func.apply(this, arguments)
previous = now
}
}
}
on.call(this, event, newFunc)
}
// 代码是Vue形式的,自行转换
getImgCodeApi:function(obj){
this.$http.get("url", {
responseType: "arraybuffer",
}).then(function (response) {
//将从后台获取的图片流进行转换
return 'data:image/png;base64,' + btoa(
new Uint8Array(response.data).reduce((data, byte) => data + String.fromCharCode(byte), '')
);
}).then(function (data) {
//接收转换后的Base64图片
obj.imgCodeUrl = data;
}).catch(function (err) {
})
},
把数据存储在本地,当设备关机重启之后还在。数据持久化最常见的一些解决方案:存文件、存数据库
数据库是一个软件系统,他通过一定的数据格式把数据存储起来。操作数据库有专门的开发语言sql(结构化查询语句)
数据库方面的工作有一个专门的岗位DBA(BataBase Administartor)
目前常见的数据库有:sqlserver,mysql,oracle,pgsql(GIS系统中使用),mongodb(nosql),sqlite(手机app中),access(微软的一个小型数据库)
内存型数据库:redis(目的是用来解决大数据量时的查询问题)
这已经是的N个我的第一个博客了