加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

reactjs – 无法安装渐进式网络应用程序站点:没有可用于显示的

发布时间:2020-12-15 20:15:12 所属栏目:百科 来源:网络整理
导读:我正在构建一个渐进的Web应用程序.我从 create-react-app开始使用样板文件.然后我添加了一个Web应用程序清单. app/public/manifest.json { "short_name": "First Contributions","name": "First Contributions","icons": [ { "src": "/android-chrome-192x19
我正在构建一个渐进的Web应用程序.我从 create-react-app开始使用样板文件.然后我添加了一个Web应用程序清单.

app/public/manifest.json

{
    "short_name": "First Contributions","name": "First Contributions","icons": [
        {
            "src": "/android-chrome-192x192.png","sizes": "192x192","type": "image/png"
        },{
            "src": "/android-chrome-256x256.png","sizes": "256x256","type": "image/png"
        }
    ],"theme_color": "#ffffff","background_color": "#ffffff","display": "standalone","start_url": "index.html"
}

将此链接到index.html

app/public/index.html

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
    <title>First Contributions</title>
  </head>
  <body>
    <div id="root"></div>
      <script>
        if ('serviceWorker' in navigator) {
          navigator.serviceWorker.register('service-worker.js').catch(function(ex) {
            console.warn(ex);
            console.warn('(This warning can be safely ignored outside of the production build.)');
          });
        }
      </script>
    </body>
  </html>

我使用realfavicongenerator.net生成了图标并将它们放在公共目录中.

我正在使用gh-pages部署我的应用程序.当我尝试添加到主屏幕时,我收到以下错误

  • android-chrome-192×192.png:1 GET 07001 404 (Not Found)
  • Error while trying to use the following icon from the Manifest: 07001 (Download error or resource isn’t a valid image)
  • Site cannot be installed: no icon available to display

我认为我在webmanifest中为图标做错了.

解决方法

您的图标路径引用根目录.

将“src”:“/ android-chrome-192×192.png”更改为“src”:“android-chrome-192×192.png”,(不包括/开头).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读