我已经经历了很多问题,可能是它重复的问题。
例外我收到了-**的“消息”:
"InvalidStateError: DOM异常11:此事务已经完成。事务在其成功或失败的处理程序被调用后提交。如果您使用承诺来处理回调,请注意遵循A+标准的实现遵循运行到完成的语义,因此承诺解析发生在随后的滴答中,因此在事务提交之后发生。“**
在React本地android应用程序中,我从离线数据中获取约会的值。其中我做了懒惰的负载。我的预约期限是10。
我有一个平面列表,我正在检查平面列表onEndReached属性。
在onEndReached属性中,我从本地数据库获取值,这里是我的函数,通过它我可以获得离线约会值
GetAllAppointment(data) {
console.log("DATA IN -------->>", data);
return new Promise((resolve, reject) => {
this.initDB().then((db) => {
db.transaction((tx) => {
getObj('skipRecord', (id) => {
var skipRecord = ((data.pageNumber - 1) * 10);
let userAppointmentList = [];
tx.executeSql("Select * from ios_Appointment where date >= " + nowDate + " and clinicianId =" + data.UserID + " and fName Like '%" + data.searchKey + "%' OR lName Like '%" + data.searchKey + "%' OR address Like '%" + data.searchKey + "%' ORDER BY (date)").then(([tx, results]) => {
if (results.rows.length > 0) {
for (let i = skipRecord; i < results.rows.length; ++i) {
userAppointmentList.push(results.rows.item(i));
}
}
let pages;
pages = results.rows.length / records;
pages = Math.ceil(pages)
let items = {
"Version": "1.2.3",
"StatusCode": 200,
"Message": "Success",
"Result": userAppointmentList,
"pagesCount": pages
}
resolve(results);
}).then((result) => {
// this.closeDatabase(db);
}).catch((err) => {
console.log("GetAllAppointment 1---->>", err);
});
}).catch((err) => {
console.log("GetAllAppointment 2---->>", err);
});
}).catch((err) => {
});
}我正在调用上面的函数到仪表板页面,在那里我将这个返回约会添加到Flalist
const db = new Database();
export default class DashboardPage extends Component {
this.page = 1;
.
.
.
handleLoadMore = () => {
if (!this.state.showLoader && (this.state.pageCount > this.page)) {
console.log("handleLoadMore page if------------------>>> ", this.state.showLoader);
this.page = this.page + 1;
this.setState({ showBottomLoader: true });
this.getData(page);
}
.
.
.
getData(body) {
let body = {
"pageNumber": page,
"searchKey": this.state.searchText,
"UserID": 1,
"currentDate": new Date().getTime()
}
db.GetAllAppointment(body).then((item) => {
let newData;
if (item) {
if (body.pageNumber == 1) {
newData = item.Result;
this.state.appointmentList.concat(item.Result)
} else {
newData = this.state.appointmentList.concat(item.Result)
}
this.setState({
showLoader: false,
appointmentList: newData,
pageCount: item.pagesCount,
showBottomLoader: false,
isRefreshing: false
})
}
}).catch((err) => {
this.setState({
showLoader: false,
appointmentList: newData,
pageCount: item.pagesCount,
showBottomLoader: false,
isRefreshing: false
})
})我第一次得到10条记录,然后得到DOM异常,如何解决这个问题:(提前谢谢
发布于 2020-01-20 13:21:48
终于解决了。
GetAllAppointment(data) {
console.log("DATA IN -------->>", data);
return new Promise((resolve, reject) => {
this.initDB().then((db) => {
getObj('skipRecord', (id) => {
db.transaction((tx) => {在事务处理之前,我正在检查本地存储的跳过记录值,然后在id执行db.transaction后,最终停止获取DOM异常:)
https://stackoverflow.com/questions/59787233
复制相似问题