一、创建spring boot后端项目,在controller中编写生成验证码的信息,通过流响应给浏览器
BufferedImage bufferedImage = new BufferedImage(100,50,BufferedImage.TYPE_INT_BGR);
log.info("创建画板开始------------------");
Graphics2D graphics = bufferedImage.createGraphics();
log.info("设置背景颜色------------------");
graphics.setColor(Color.WHITE);
graphics.setBackground(Color.WHITE);
graphics.fillRect(0,0,100,50);
List |
二、创建vue脚手架前端项目,当页面加载的时候发送axios请求进行获取。
created:function () {
console.log(111111);
axios.get("/api/dxq/getCode",{responseType: 'blob'}).then(res=>{
console.log(res.data);
console.log(window.URL.createObjectURL(res.data));
this.codeUrl = window.URL.createObjectURL(res.data);
// this.routers = res.data.data;
}).catch(err=>{
alert("查询出错!");
});
} |
三、结果:



