注:如果不是和pyqt/PySide2直接相关程序,请查阅其他解决方案。
问题描述:
1.环境:PySide2, Python3.6.8,arcgis JavaScript API 4.14。
2.现象:新建HTML和js文件,通过arcgis JavaScript API 调用basemap。直接用浏览器打开HTML,运行正常,但是通过PySide2的QWebEngineView调用时,会报出如下错误:
*** has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’
header is present on the requested resource. If an opaque response
serves your needs, set the request’s mode to ‘no-cors’ to fetch the
resource with CORS disabled.
3.解决方法:在实例化
self.browser=QWebEngineView()
之后,需要调用: