【问题标题】:No Manifest Detected on a PHP Progressive Web Application在 PHP 渐进式 Web 应用程序上未检测到清单
【发布时间】:2021-02-06 00:41:19
【问题描述】:

我正在尝试将我的 PHP Web 应用程序变成一个渐进式 Web 应用程序,但是当我在应用程序选项卡中打开 Chrome DevTools 时,当我将 manifest.json 放在root 但我的 ServiceWorker.js 已成功运行。

<!DOCTYPE html>
<html lang="en">

<?php
//php code
?>

<head>
    <title>php</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="manifest" href="/manifest.json">
    <link rel="stylesheet" type="text/css" href="css/util.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">

</head>

<body>
//body code
</body>

</html>
{
"name": "php",
"version": "1.0",
"short_name": "php",
"start_url": "./index.php",
"background_color": "#000000",
"display": "standalone",
"orientation": "any",

"default_locale": "en",
"description": "example",
"icons": [

    {
        "src": "512x512.png",
        "sizes": "512x512",
        "type": "image/png"
    },

    {
        "src": "192x192.png",
        "sizes": "192x192",
        "type": "image/png"
    }

]}

我在这里验证了 manifest.json 文件,它可以在测试 HTML 文件中运行;它只是试图将它放入一个 PHP 文件中,我没有看到任何事情发生。

【问题讨论】:

    标签: php progressive-web-apps manifest


    【解决方案1】:

    将您的&lt;head&gt;&lt;/head&gt; 块直接移动到打开的&lt;html&gt; 标记下方,以便您的&lt;?php //php code ?&gt; 在它下方。如果文档头之前有任何输出,则不会检测到清单。

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <title>php</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="manifest" href="/manifest.json">
        <link rel="stylesheet" type="text/css" href="css/util.css">
        <link rel="stylesheet" type="text/css" href="css/main.css">
    </head>
    
    <?php
      //php code
    ?>
    
    <body>
      //body code
    </body>
    
    </html>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-07
      • 2017-04-27
      • 2018-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多