【问题标题】:net::ERR_CONNECTION_REFUSED - Access project file inside my Meteor app from inappbrowsernet::ERR_CONNECTION_REFUSED - 从 inappbrowser 访问我的 Meteor 应用程序中的项目文件
【发布时间】:2016-11-17 21:49:41
【问题描述】:

我是 Meteor 和 React 的新手,正在用它构建我的第一个 Android 应用(我在 Angular1 上)。

这个应用程序里面有很多小游戏,我正在尝试从我的 resources/ 文件夹中提供这些游戏。

我的问题是:当我点击一个标题时,一个应用浏览器窗口弹出,我想在那里提供我的游戏。

我尝试了很多方法来打开 resources/games/meme/index.html 中的文件,但我总是得到:net::ERR_CONNECTION_REFUSEDnet::ERR_FILE_NOT_FOUND(最后一个是我用file:///games/meme/index.html)

这是我的代码:

// here I have some settings
const inAppOptions = 'location=no,clearcache=yes,toolbar=no';
const target = '_blank';

// and here the code itself
if (Meteor.isCordova) {
    Meteor.startup(function() {
        let ref = cordova.InAppBrowser.open('file:///games/meme/index.html', target, inAppOptions);
        ref.addEventListener('exit', () => cordova.InAppBrowser.close());
    });
}

到目前为止,我已经尝试了 let ref = cordova.InAppBrowser.open('file:///games/meme/index.html', target, inAppOptions); 行: 'file:///games/meme/index.html' '/games/meme/index.html' '/resources/games/meme/index.html' 'resources/games/meme/index.html'

我还将游戏/文件夹及其内容放在 public/ 目录中,结果相同。

我安装了 cordova-whitelist 插件,并在 mobile-config.js 中安装了 App.accessRule('*', {type: 'navigation'});

这是我的文件夹结构:

MyApp
├── .meteor
├── client
├── imports
├── node_modules
├── public
│   ├── games
│   │   ├── meme
│   │   │   ├── index.html
│   ├── img
├── resources
│   ├── games
│   │   ├── meme
│   │   │   ├── index.html
│   ├── icons
│   ├── splash
├── server
│   mobile-config.js
│   package.json

我希望有人可以帮助我,我没有遇到 ionic 角度的这个问题,根文件夹就是我所在的位置,所以我必须像这样导航:'../../resources/games/meme/index.html' 才能访问该文件。

提前致谢!

编辑: 我尝试在 chrome://inspect 中手动写入地址,并成功访问如下:localhost:12200/games/meme/index.html(这是在 public/文件夹),但我不能在 inappbrowser 中使用相同的地址。

【问题讨论】:

    标签: cordova meteor reactjs inappbrowser


    【解决方案1】:

    这里只是猜测,但我知道在使用 React Native 为 Android 开发时,我不能使用 localhost,因为它无法解决。尝试将 localhost 换成您机器的 IP 地址。

    【讨论】:

    • 感谢 Spencer!,我们决定将第二个应用程序直接包含在流星项目中,这意味着:通过常规路线访问它,无需 inappbrowser。它更容易,我们不必处理这类问题。我会将此标记为正确,因为我相信这也是我的问题。感谢您的帮助!
    猜你喜欢
    • 2014-03-27
    • 2021-09-07
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 2021-07-01
    • 2011-06-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多