【发布时间】:2019-09-11 10:58:58
【问题描述】:
我的 Vue SPA 中出现以下错误:
Refused to execute inline script because it violates the following Content Security
Policy directive: "default-src 'self'". Either the 'unsafe-inline' keyword,
a hash ('sha256-KpHv3zgivMSB4dPnfYfqMt2lBibsYvM36EdoBBAsfbM='), or a nonce ('nonce-...')
is required to enable inline execution. Note also that 'script-src' was not explicitly set,
so 'default-src' is used as a fallback.
这个错误是由Browsersync引起的:
首先,仅当浏览器已由非根路由中的 browsersync 重新加载时才会发生此错误。比如这个错误发生在http://localhost:3001/sign-in,但是从来没有发生在http://localhost:3001。
接下来,这个错误只发生在 SPA 中,而不会发生在普通网站中(多个页面,没有对 HTML5 历史的操作)。所以,我想,vue-router 参与其中。
【问题讨论】:
标签: vue.js single-page-application vue-router browser-sync