跨域报错的原因
最开始上传视频成功后,video标签的src会直接引入上传后的服务端资源地址,然后使用canvas截图就发生了跨域报错的提示。
Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
按网上说的方法设置video标签的属性 crossorigin="anonymous"
,还是报错,原因是服务端的请求头没设置,不允许跨域访问。
Failed to load http://xxxx.oss-cn-shenzhen.aliyuncs.com/2018/08/22/1749/VU0SL0msslJvN1q3YNN2fmr1E4zmmE0vmHTV7A9s.mp4: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
解决办法: 视频上传成功后,不要引入线上地址,仍然使用本地视频地址,即可解决跨域问。