亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

React Web Extension 錯誤:拒絕應用內聯樣式,因為它違反了以下內容安全

React Web Extension 錯誤:拒絕應用內聯樣式,因為它違反了以下內容安全

互換的青春 2023-01-06 16:10:48
我以前曾合作過,React Js但這是我第一次使用 React 進行 Web 擴展。My manifest.json file is:{  "manifest_version": 2,  "name": "owl",  "author": "zubayr",  "version": "1.0.1",  "description": "Testing!",  "icons": {    "16": "owl.png",    "48": "owl.png",    "128": "owl.png"  },  "browser_action": {    "default_popup": "index.html",    "default_title": "Open the popup"  },  "permissions": ["storage"]}我有一個奇怪的錯誤:Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem:". Either the 'unsafe-inline' keyword, a hash ('sha256-1kri9uKG6Gd9VbixGzyFE/kaQIHihYFdxFKKhgz3b80='), or a nonce ('nonce-...') is required to enable inline execution.請讓我知道出了什么問題。我的index.html文件是:<!DOCTYPE html><html>  <head>    <meta charset="utf-8" />    <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />    <meta name="viewport" content="width=device-width, initial-scale=1" />    <meta name="theme-color" content="#000000" />    <meta http-equiv="Content-Security-Policy" content="base-uri 'self'; object-src 'none'; script-src 'self' 'sha256-GgRxrVOKNdB4LrRsVPDSbzvfdV4UqglmviH9GoBJ5jk='; style-src 'self'">    <meta      name="description"      content="Web site created using create-react-app"    />    <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />    <style>    .myDiv {      border: 50px outset red;      background-color: '#000000';      text-align: center;    }    div {  height: 200px;  width: 50%;  background-color: powderblue;}另外,當我在 chrome 中以開發人員模式運行擴展程序時,彈出窗口與圖像一樣大。我似乎無法根據自己的意愿增加它的高度寬度。如果可能的話,也請告訴我它的解決方案。
查看完整描述

1 回答

?
慕萊塢森

TA貢獻1810條經驗 獲得超4個贊

Chrome 安全性阻止了 create-react-app 生成的內聯 JS。嘗試這個

在您的 React 應用程序中,請創建一個.env或將其添加到現有應用程序中

INLINE_RUNTIME_CHUNK=false

然后構建您的應用程序(例如。yarn run build

使用這個,沒有獨立于大小的腳本被內聯。

查看此拉取請求以獲取更多詳細信息https://github.com/facebook/create-react-app/pull/5354


查看完整回答
反對 回復 2023-01-06
  • 1 回答
  • 0 關注
  • 147 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號