1. 程式人生 > 其它 >Refused to execute inline script because it violates the following Content Security Policy 指令碼報錯已解決

Refused to execute inline script because it violates the following Content Security Policy 指令碼報錯已解決

技術標籤:前端htmljs

寫了一個功能 發現指令碼報錯以為是我的 jar 包引錯了?還是位置反了?經過捯飭才發現這些都不是看下面是具體的報錯

Failed to load resource: the server responded with a status of 404 (Not Found)

upload.html:9 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-2/nwTfnmhsEOQ+pVDGpNeMyOzp4HRtQri8QvvBb+A6Q='), 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.

upload.html:9 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-kPY6ovEPaw5y+RgWpejDaoJa2JT9tURMxvKvnhgv1XM='), 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.

在這裡插入圖片描述

其實是違反了一些規則

我用谷歌進行的頁面展示 ,我寫的html有button按鈕 這個識別不了。
將type改成button型別就行了,因為除了ie其他瀏覽器預設是submit。
如下圖

在這裡插入圖片描述
修改一下就好了 問題就解決了