Vue3 引用百度地图部署到服务器,地图展示不出来。

浏览器报错信息:

because it violates the following Content Security Policy directive: "script-src * 'unsafe-inline' 'unsafe-eval'". Note that 'worker-src' was not explicitly set, so 'script-src' is used as a fallback. Note that '*' matches only URLs with network schemes ('http', 'https', 'ws', 'wss'), or URLs whose scheme matches self's scheme. The scheme 'blob:' must be added explicitly.

我在index.html中通过以下方式引用的

原因:浏览器报错是因为违反了内容安全策略(Content Security Policy, CSP)中的 script-src 指令。具体来说,CSP 策略不允许加载 blob: 方案的脚本资源。如何我在nginx中加了下面这段话,就那么水灵灵的展示出来了!!!

  Content-Security-Policy: script-src * 'unsafe-inline' 'unsafe-eval' blob:;

 

你可能感兴趣的:(服务器,前端)