下载页面中的图片
下载页面中的图片
downLoadBtn(name){
const image = new Image();
image.setAttribute('crossOrigin', 'anonymous')
image.onload = function () {
const canvas = document.createElement('canvas')
canvas.width = image.width
canvas.height = image.height
const context = canvas.getContext('2d')
context.drawImage(image, 0, 0, image.width, image.height)
const url = canvas.toDataURL('image/png')
const a = document.createElement('a')
const event = new MouseEvent('click')
a.download = '远程抓拍图片'
a.href = url
a.dispatchEvent(event)
}
image.src = this.imgSrc;
},
vue截取video视频中的某一帧
vue截取video视频中的某一帧
remoteCapture(){
var v = document.querySelector(".video");
let canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.drawImage(v, 0, 0, 343, 200);
var oGrayImg = canvas.toDataURL('image/jpeg');
this.imgSrc = oGrayImg;
},
web端录制视频并保存本地
web端录制视频并保存本地
saveVedio(url,name){
var xhr = new XMLHttpRequest();
console.log(xhr,'xhr');
url = url.replace('//f.video.weibocdn.com/','/weibo/');
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
let blob = this.response;
let downLoadUrl = window.URL.createObjectURL(new Blob([blob], {
type: 'video/mp4'
}));
let a = document.createElement('a');
a.download = name;
a.href = downLoadUrl;
a.style.display = 'none';
document.body.appendChild(a);
a.click();
a.remove();
};
};
xhr.send();
---------这两个都不管用----------
var a = document.createElement('a');
a.href = url;
a.download = '保存的录像.mp4';
a.style.display = 'none';
console.log(a,'a标签');
document.body.appendChild(a);
a.click();
a.remove();
},
- 奥i是否会
- 迫使附件
- 是v