我使用 Ionic 5 和 angular 。我的頁面系結到一個物件((人))。當我從 websql 中選擇資料時,我的物件會更新,但頁面不會更新,直到我單擊選單或其他控制元件
//this code is in my component in the click button
//jsonData initial
jsonData["SelectFunctionInSuccess"] = (result)=>{
this.Person.Id = result[0].Id;
this.Person.Code = result[0].Code;
this.Person.Name = result[0].Name;
this.Person.Family = result[0].Family;
}
this.crudManager.SelectData(jsonData);//<= this is call websql
//**************************************************
//in the websql class
// QueryStatement is declare and set correct it is string variable
this.db.readTransaction(function (tx) {
tx.executeSql(QueryStatement, [], function (tr, results) {
jsonData.SelectFunctionInSuccess(results.rows);
});
}, this.getError);
選擇運行,我得到資料。人是更新但html沒有更新
uj5u.com熱心網友回復:
前段時間我遇到了類似的問題。您進行外部呼叫,此時 Ionic 更新頁面的行為略有不同。您需要重繪 頁面,這可以使用以下代碼完成:
constructor(public appRef: ApplicationRef) {}
當你想重繪 時:
this.appRef.tick();
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/369050.html
