執行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)