1)使用
useCORS:true或使用
proxy,切勿同时使用两者。
2)您的路线不同,请参阅:
virtual_path = '/gpsDataMap/images/'
@surveyApp_module.route('/gpsDataMap/html2canvas/images/<image>')
"proxy":"/surveyApp/gpsDataMap/html2canvas-proxy",
@surveyApp_module.route('/gpsDataMap/html2canvas-proxy')
您没有意识到所有错误,为什么
userCORS与“ PROXY”混淆。
修复所有路由(路由是其虚拟路径)并修复您的Javascript(不要使用
userCORS:),请参阅:
$(window).load(function(){ $('#saveMap').click(function(){ html2canvas(document.getElementById('map'), { "logging": true, //Enable log (use Web Console for get Errors and Warnings) //useCORS:true, "COMMENTED", remove useCORS "proxy": YOUR_FIXED_ROUTE, "onrendered": function(canvas) { var img = new Image(); img.onload = function() { img.onload = null; document.body.appendChild(img); }; img.onerror = function() { img.onerror = null; if(window.console.log) { window.console.log("Not loaded image from canvas.toDataURL"); } else { alert("Not loaded image from canvas.toDataURL"); } }; img.src = canvas.toDataURL("image/png"); } }); });});
看,这是与“路线”混合的绝对路径:
GEThttp://127.0.0.1:5555/home/bhim/app/surveyApp_bhim/images/a0af53c02bd2f2aed37f1d895edcf3485117c512.png404 (NOT FOUND) html2canvas.js:2249
代理响应路由由于任何原因是错误的,请使用以下命令:
1)编辑您的代码,如下所示:
@surveyApp_module.route('/gpsDataMap/html2canvas-proxy')def html2canvas_proxy(): print ("is this proxy really calling "); h2c = html2canvasproxy(request.args.get('callback'), request.args.get('url')) h2c.userAgent(request.headers['user_agent']) if request.referrer is not None: h2c.referer(request.referrer) if request.args.get('debug_vars'): #Added return Response((',n'.join(h2c.debug_vars())), mimetype='text/plain') #Added h2c.route(real_path, virtual_path) r = h2c.result() return Response(r['data'], mimetype=r['mime'])
2)在浏览器中运行:
http://127.0.0.1:5000/gpsDataMap/html2canvas-proxy?callback=console.log&url=http://www.google.com&debug_vars=1
3)获得结果并发布在您的任务中。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)