【问题标题】:use Live reload when index file is in a folder当索引文件在文件夹中时使用 Live reload
【发布时间】:2016-11-21 16:50:30
【问题描述】:

我写了一个混合应用程序,我的目录结构将索引放在 www 内的一个文件夹中,目录看起来像

cordova/wwww/SomeFolder/index.html

我把它写在cordova config.xml 文件中:

<content src="SomeFolder/index.html"/>

当我制作时

ionic run android --device

一切正常,该应用程序已安装在设备中并且运行良好。

问题是当我尝试使用 livereload 时:

ionic run -l android --device

应用程序已安装在设备中但无法运行,出现关于找不到文件索引的消息

在这个阶段,我可以在浏览器中打开应用程序,说不是 wroks,但如果我添加文件夹名称,我可以打开应用程序:

10.0.23.4:8100/SomeFolder/

问题是当我在浏览器中保存修改时出现 msg 404,我确实将地址更改为 10.0.23.4:8100/SomeFolder/ 重新加载并导航到我工作的地方,这很乏味。

是否有一种方法可以将 livereload 配置为在文件夹中而不是在根文件夹 www 中搜索索引?

【问题讨论】:

    标签: cordova ionic-framework configuration hybrid-mobile-app livereload


    【解决方案1】:

    @Pablote:您尝试过以下方法吗

    1. 在 app.js 的 config state provider 部分下添加一个新状态。

    .config(function($stateProvider, $urlRouterProvider) {
      $stateProvider
    
        .state('some-folder', {
        cache: false,
        url: '/somefolder',
        templateUrl: "SomeFolder/index.html",
      })
    });
    1. 现在您使用 URL:http://localhost:8100/somefolder/ 打开浏览器,因为我们将 url 设置为 /some-folder。修改您的代码并保存,然后查看实时重新加载是否有效。

    【讨论】:

    • 不适用于此解决方案,因为 SomeFolder/index.html 是第一页,因此系统在收费 angular 之前确实会进入那里
    • 我在 Config.xml 中使用 行并在应用程序中工作但在 livereload 中不工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 2012-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多