2015-05-04 90 views
7

啓動時運行離子成爲我看到這一點:離子服務在本地主機上,而不是服務器的IP

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更改爲實際的服務器IP?

感謝

回答

17
`ionic address` 

給出的地址的列表。選擇一個

如:

Multiple addresses available. 
Please select which address to use by entering its number from the list below: 
1) 10.0.0.9 (wlan0) 
2) 172.16.58.1 (vmnet1) 
3) 172.16.16.1 (vmnet8) 
4) localhost 
Std in before prompt 
Address Selection: 
+0

使用非常感謝你,我不知道我怎麼錯過了:) – lulu88

+0

哇,我沒有得到任何來自'離子address'輸出所以我用'離子服務地址xx.xx.xx.xx'(127.0.0.1/localhost是我想要的) – Jacksonkr

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到Learn more options

老答案:

使用-address localhost

運行

ionic serve -address localhost 

測試在多個屏幕尺寸您的應用程序和平臺類型的--lab

ionic serve --lab -address localhost 
+0

我正在嘗試這個,但沒有運氣。我猜Ionic已經把這個命令改成了別的東西。 – Tanzeel

+1

@Tanzeel感謝您指出這一點,它已在新版本更新,我剛剛更新了相應的答案,希望這會有所幫助。謝謝。 –

相關問題