ionic serve在localhost而不是服务器IP上启动

时间:2015-05-04 11:56:15

标签: cordova ionic-framework ionic

运行离子发球时,我看到了:

  Gulp startup tasks: [ 'sass', 'watch' ]
  Running dev server: http://localhost:8100
  Running live reload server: http://localhost:35729
  Watching : [ 'www/**/*', '!www/lib/**/*' ]
  Ionic server commands, enter:
    restart or r to restart the client app from the root
    goto or g and a url to have the app navigate to the given url
    consolelogs or c to enable/disable console log output
    serverlogs or s to enable/disable server log output
    quit or q to shutdown the server and exit

这意味着我无法从浏览器访问应用程序,因为它只侦听localhost。如何将localhost更改为实际的服务器IP?

由于

2 个答案:

答案 0 :(得分:19)

KieSession ksession = //however you gain access to your ksession
ksession.addEventListener(new CustomProcessEventListener());

给出一个地址列表。选择一个

例如:

`ionic address`  

答案 1 :(得分:3)

新答案:

对于较新版本的离子,已更改为--address

  • ionic address命令提供选择IP地址的选项。您可以从。

  • 中选择一个
  • 您可以明确地定义IP地址和端口,如下所示:

    ionic serve --address address --port port //8100 is default

    示例1:ionic serve --address localhost --port 8101

    示例2:ionic serve --address localhost --port 8101

  • 尝试使用--lab选项一次查看多个平台。

    ionic serve --address localhost --lab

Clikc to Learn more options

OLd答案:

使用-address localhost

运行

ionic serve -address localhost

使用--lab

在多种屏幕尺寸和平台类型上测试您的应用
ionic serve --lab -address localhost
相关问题