【发布时间】:2016-11-17 21:49:41
【问题描述】:
我是 Meteor 和 React 的新手,正在用它构建我的第一个 Android 应用(我在 Angular1 上)。
这个应用程序里面有很多小游戏,我正在尝试从我的 resources/ 文件夹中提供这些游戏。
我的问题是:当我点击一个标题时,一个应用浏览器窗口弹出,我想在那里提供我的游戏。
我尝试了很多方法来打开 resources/games/meme/index.html 中的文件,但我总是得到:net::ERR_CONNECTION_REFUSED 或 net::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