![](/img/trans.png)
[英]Ionic Cordova $http POST data works well in browser but does not work in my android phone
[英]SQLite Cordova (Ionic) does not work on phone or another computer, but works on bluestacks
當我正在運行的離子應用程序運行時,如果我使用bluestacks在計算機上運行該應用程序,則它可以運行,但是當我嘗試在手機上運行該應用程序時,它將無法運行。 同樣,在同事的計算機上,它也不起作用。
錯誤代碼為“應用程序錯誤
與服務器的連接失敗。 ( http://192.168.201.55:8100 )”
通常后跟“應用程序錯誤net :: ERR_CONNETION_TIMED_OUT(與上述IP地址相同)”
不用說,我不是在嘗試使用在線數據庫,而是在使用離線數據庫。 這是我代碼的相關部分,如果您認為自己需要更多信息,我將提供所有相關信息,以找出如何修復我的代碼。
private database: SQLiteObject;
private dbReady = new BehaviorSubject<boolean>(false);
constructor(private platform:Platform, private sqlite:SQLite) {
this.platform.ready().then(()=>{
this.sqlite.create({
name: 'todos.db',
location: 'default'
})
.then((db:SQLiteObject)=>{
this.database = db;
this.createTables().then(()=>{
//communicate we are ready!
this.dbReady.next(true);
});
})
});
}
嘗試將ip添加到index.html(這可能是CSP問題):
<meta http-equiv="Content-Security-Policy" content="default-src 'self' gap://ready file://*
http://192.168.201.55:8100
... other ip addresses ...
data: gap:;
style-src 'self' 'unsafe-inline';
media-src *;
script-src 'self' 'unsafe-inline' 'unsafe-eval'"
和https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.