ionic 运行到真机上报错 net::ERR_CONNECTION_REFUSED (http://localhost:8100/)

执行ionic cordova run android 时,APP在手机上一启动就直接报错net::ERR_CONNECTION_REFUSED (http://localhost:8100/)。

找了半天,在官方论坛上看到一个贴子:

https://forum.ionicframework.com/t/net-err-connection-refused-http-localhost-8080/137126/31

这里面有一条解决了我的问题:

就是之前不知道为什么,config.xml中的<content>被修改了,(config.xml是cordova的全局性配置文件)我这里报错时的样子:

    <content src="index.html" />
    <content original-src="index.html" src="http://localhost:8100" />

应该就是这个src="http://localhost:8100"导致启动报错,这个content应该是APP启动时要加载的文件,正常当然是index.html。

删除上面第二行只保留<content src="index.html" />,问题就解决了。

config.xml

官方文档中文(https://www.jianshu.com/p/01600b624950

官方文档英文(https://cordova.apache.org/docs/en/latest/config_ref/index.html

原文地址:https://www.cnblogs.com/johnjackson/p/14026081.html