0

我正在尝试设置我的 facebook 即时游戏。

我已关注https://developers.facebook.com/docs/games/instant-games/test-publish-share,在本地测试然后部署到生产中。

测试时,一切正常。但是,在生产中,当我打开游戏时,什么都没有显示(黑屏)。<app-root>不渲染,app-home 的构造函数没有被调用,它占用 0x0 像素。

这是我的 index.html

<!--
  Copyright (c) 2017-present, Facebook, Inc.
  All rights reserved.
  This source code is licensed under the license found in the
  LICENSE file in the root directory of this source tree.
-->

<!DOCTYPE html>
<html>

<head>

  <meta charset="utf-8">
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="full-screen" content="yes" />
  <meta name="screen-orientation" content="portrait" />
  <meta name="viewport" content="user-scalable=no" />

  <script type="module" src="/build/app.esm.js"></script>
  <script nomodule src="/build/app.js"></script>
  <link href="/build/app.css" rel="stylesheet">
  <link rel="apple-touch-icon" sizes="180x180" href="/assets/icon/apple-touch-icon.png">
  <link rel="icon" type="image/x-icon" href="/assets/icon/favicon.ico">
  <link rel="manifest" href="/manifest.json">
</head>

<body>
  <script src="https://connect.facebook.net/en_US/fbinstant.6.2.js"></script>
  <script type="text/javascript">

    const assets = [
      'img/asset1.png',
      'img/asset2.png',
      'img/asset3.png',
      'img/asset4.png'
    ];

    window.onload = function () {

      // When the window loads, start to initialize the SDK
      FBInstant.initializeAsync().then(function () {

        // We can start to load assets
        for (let i in assets) {
          // When preloading assets, make sure to report the progress
          FBInstant.setLoadingProgress(i / assets.length * 100);
        }

        // Now that assets are loaded, call startGameAsync
        FBInstant.startGameAsync().then(() => console.log("initialized"));
      });
    };
  </script>

  <app-root></app-root>

</body>

</html>

当我打开游戏时,控制台中会打印“已初始化”。它有两个错误(可能与我遇到的错误有关) 控制台日志

404 错误(找不到资源)是一个 .js 文件,我检查过它包含在我上传的 .zip 文件中。

这是我在游戏 检查元素上检查元素时看到的

此外,在移动设备上,什么也没有显示(白屏)

任何帮助将不胜感激。谢谢!:)

4

0 回答 0