base64图片复制

vue

$vue->method("copy_base64_data(data)","   
        location.origin.includes(`https://`) || Message.error(`图片复制功能不可用`);
        data = data.split(';base64,'); let type = data[0].split('data:')[1]; data = data[1]; 
        let bytes = atob(data), ab = new ArrayBuffer(bytes.length), ua = new Uint8Array(ab);
        [...Array(bytes.length)].forEach((v, i) => ua[i] = bytes.charCodeAt(i));
        let blob = new Blob([ab], { type }); 
        navigator.clipboard.write([new ClipboardItem({ [type]: blob })]);
");

PHP中返回的data值

'data:image/png;base64,'.base64_encode($content)