首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"InvalidStateError: DOM异常11:此事务已经完成。“

"InvalidStateError: DOM异常11:此事务已经完成。“
EN

Stack Overflow用户
提问于 2020-01-17 12:19:33
回答 1查看 701关注 0票数 1

我已经经历了很多问题,可能是它重复的问题。

例外我收到了-**的“消息”:

"InvalidStateError: DOM异常11:此事务已经完成。事务在其成功或失败的处理程序被调用后提交。如果您使用承诺来处理回调,请注意遵循A+标准的实现遵循运行到完成的语义,因此承诺解析发生在随后的滴答中,因此在事务提交之后发生。“**

在React本地android应用程序中,我从离线数据中获取约会的值。其中我做了懒惰的负载。我的预约期限是10。

我有一个平面列表,我正在检查平面列表onEndReached属性。

在onEndReached属性中,我从本地数据库获取值,这里是我的函数,通过它我可以获得离线约会值

代码语言:javascript
复制
  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

代码语言:javascript
复制
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异常,如何解决这个问题:(提前谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-20 13:21:48

终于解决了。

代码语言:javascript
复制
 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异常:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59787233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档