科尔多瓦Android模拟器 - 如何使用本地主机? [英] Cordova android emulator - how to use local host?

查看:119
本文介绍了科尔多瓦Android模拟器 - 如何使用本地主机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个使用REST API的应用程序。后端是我的本地机器上,所以我有这个

I'm trying to create an application that uses rest api. The backend is on my local machine, so I've got this

127.0.0.1   api.mail.my

/ etc / hosts中

在应用我有以下内容:

var messageResource = $resource('http://api.mail.my/messages/:folder/:id');

该工程确定,通过浏览器访问这个应用程序的时候。

which works ok, when accessing this app via browser.

但我怎么让这个程序访问资源,当它在模拟器中运行(科尔多瓦模拟机器人)?

But how do I make this app to access the resource, when it's being run in an emulator (cordova emulate android)?

推荐答案

当您在模拟器上使用localhost,它指的是模拟器本身的IP,而不是一个您的计算机。

when you use localhost on the emulator, it refers to the ip of the emulator itself, not the one of your computer.

您必须让你的计算机的本地IP,并使用它,而不是使用localhost或127.0.0.1。

You have to get the local ip of your computer and use it instead of localhost or 127.0.0.1.

这篇关于科尔多瓦Android模拟器 - 如何使用本地主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆