Vue中插入base64图片实现方式
作者:合衬i
文章主要讲述了在Vue中插入base64图片的方法,包括在模板中写入img标签、在methods中写入事件以及调用后端接口,作者分享了个人经验,希望能为读者提供参考
Vue插入base64图片
1.template模板中写入img标签
<!-- base64图片 --> <img :src="formLabelAlign.deptPic" />
2.methods中写入事件
cargoinfo.examineshow({ id: row.id }).then((response) => {
if (response.status == 200) {
this.formLabelAlign = response.data;
this.formLabelAlign.deptPic = `data:image/png;base64,${response.data.deptPic}`;
}
});3.调后端接口
// 下载预览
function examineshow(params) {
return request({
url: `/epidemic/examine/show`,
method: 'get',
params
})
}总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
