第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

當(dāng) React 應(yīng)用程序由 firebase 部署和托管時出現(xiàn)空白頁面

當(dāng) React 應(yīng)用程序由 firebase 部署和托管時出現(xiàn)空白頁面

繁華開滿天機(jī) 2023-09-28 17:23:52
通過 firebase 部署網(wǎng)站域后,我收到一個空白頁面 - 我知道我做錯了什么,我對運(yùn)行 firebase init 時覆蓋索引/html 文件的選項(xiàng)說了(是)。我嘗試通過各種方法解決這個問題,我已經(jīng)替換了 firebase 生成的 build 文件夾中的 index.html 文件,并添加了所需的基本和腳本標(biāo)簽,所以現(xiàn)在至少加載了空白頁面和 React 應(yīng)用程序名稱登錄選項(xiàng)卡顯示它正在加載。但是內(nèi)容沒有顯示。我嘗試將 firebase.json 更改為 ["hosting": {"public": "dist",] 因?yàn)樗畛跏?["hosting": {"public": "build",] 但是這并沒有像我那樣工作在 cmd 上收到此錯誤:錯誤:指定的公共目錄“dist”不存在,無法將托管部署到站點(diǎn)...相關(guān)代碼如下,如果您需要更多代碼片段,請?jiān)u論。構(gòu)建/index.html<!DOCTYPE html><html><head>  <meta charset="utf-8" />  <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />  <meta name="viewport" content="width=device-width, initial-scale=1" />  <meta name="theme-color" content="#000000" />  <base href="https://contact-form-fba60.firebaseapp.com/">  <script type="text/javascript" src="https://contact-form-fba60.firebaseapp.com/runtime.a66f828dca56eeb90e02.js"></script>  <script type="text/javascript" src="https://contact-form-fba60.firebaseapp.com/main.2eb2046276073df361f7.js" ></script>  <meta name="description" content="Web site created using create-react-app" />  <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />  <!--      manifest.json provides metadata used when your web app is installed on a      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/    -->  <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />  <!--      Notice the use of %PUBLIC_URL% in the tags above.      It will be replaced with the URL of the `public` folder during the build.      Only files inside the `public` folder can be referenced from the HTML.      Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will      work correctly both with client-side routing and a non-root public URL.      Learn how to configure a non-root public URL by running `npm run build`.    -->  <title>React App</title></head></body></html>
查看完整描述

3 回答

?
aluckdog

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個贊

將 URL 重寫為 index.html 時應(yīng)選擇“N”。

所以,我建議你重做firebase初始化。


查看完整回答
反對 回復(fù) 2023-09-28
?
鳳凰求蠱

TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超4個贊

嘗試“公共”:“./”



查看完整回答
反對 回復(fù) 2023-09-28
?
守著星空守著你

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超8個贊

您需要設(shè)置PUBLIC_URLwebpack 構(gòu)建包所需的環(huán)境變量。

在生成的 html 中,文件中不應(yīng)包含%PUBLIC_URL%字符串,build /index.html例如:<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />,它應(yīng)該有完整的 url,例如:<link rel="icon" href="https://<your-app-name>.firebaseapp.com/favicon.ico" />

要解決這個問題:

GitHub部分:

  1. 轉(zhuǎn)到 Githup 中的存儲庫,然后單擊 repo settings

  2. 在存儲庫設(shè)置側(cè)欄上,展開Secrets and variables菜單項(xiàng),然后單擊actions。

  3. 在頁面上Actions secrets and variables,單擊Variables選項(xiàng)卡,然后單擊New repository variable

  4. 在頁面上Actions variables / New variable填寫,然后單擊。NamePUBLIC_URLValuehttps://<your-app-name>.firebaseapp.comAdd variable

回購代碼部分:

  1. 打開.github/workflows/firebase-hosting-merge.yml并添加

env: 
 PUBLIC_URL: ${{ vars.PUBLIC_URL }}

上面的name: Deploy to Firebase Hosting on merge線。

  1. 提交更改并推送。

注意:確保將 firebase 托管公共目錄設(shè)置為文件buildfirebase.json。

{

  "firestore": {

    "rules": "firestore.rules",

    "indexes": "firestore.indexes.json"

  },

  "hosting": {

    "public": "build",

    "ignore": [

      "firebase.json",

      "**/.*",

      "**/node_modules/**"

    ]

  }

}


查看完整回答
反對 回復(fù) 2023-09-28
  • 3 回答
  • 0 關(guān)注
  • 155 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號