下载了pdfjs-4.0.379-dist,但是直接打开viewer.html报错。解决方法:安装live Sever,并用live Server打开
打开浏览器截图
错误提示如下:
Access to image at 'file:///D:/work/web-common/car-knowledge-base-web/static/pdfjs-4.0.379-dist/web/images/toolbarButton-zoomOut.svg' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.
错误截图:
这是因为直接打开目录下的文件跨域了。
解决
安装live-server,并使用live-server打开。