收藏
回答

wx.showToast 提示框在模拟器正常 ,预览手机端不显示或者闪一下,为什么?

wx.showToast({ title: '保存成功!', icon: 'none', duration: 20000 });


回答关注问题邀请回答
收藏

2 个回答

  • hello world
    hello world
    03-29

    loading和toast会互相覆盖掉

    03-29
    有用
    回复 1
    • 朔
      03-29
      好嘞感谢大佬
      03-29
      回复
  • 朔
    03-29

    async saveCarInfo() {

          const { plate = '', wecarId = '' } = this.data;

          const checkMsg = this.checkPlate(plate);

          if (checkMsg !== '') {

            wx.showToast({ title: checkMsg, icon: 'none', duration: 20000 });

            return;

          }

          wx.showLoading();


          try {

            let carInfo = { wecarId: '' };

            if (wecarId) {

              carInfo = await this.updateCar({ plate }, wecarId);

              wx.showToast({ title: '保存成功!', icon: 'none', duration: 20000 });

              this.getCars();

              this.setData({

                showEditDrawer: false,

              });

            } else {

              carInfo = await this.createNewCar({ plate });

              const { wecarId: addWecarId = '' } = carInfo;

              this.setData({ wecarId: addWecarId });

              wx.showToast({ title: '保存成功!', icon: 'none', duration: 20000 });

              this.getCars();

              this.setData({

                showEditDrawer: false,

              });

              return;

            }


            // 更新当前车

            // tms.getCarManager().setCarInfo(carInfo);

            // this.getAppendQuery();

            // this.navigateToPage();

            wx.hideLoading();

          } catch (e) {

            if (e.errCode !== 0) {

              wx.showToast({ title: e.errMsg, icon: 'none', duration: 20000 });

            }

            wx.hideLoading();

            // const showModalObj = C.handleSaveCarInfoError(e);

            // showOcrModal(showModalObj);

          }

        },

    整体代码是这样的

    03-29
    有用
    回复 3
    • 简|ω・)°
      简|ω・)°
      03-29
      03-29
      回复
    • 简|ω・)°
      简|ω・)°
      03-29
      你执行完 wx.showToast({ title: '保存成功!', icon: 'none', duration: 20000 });再执行wx.hideLoading();就有这个问题了
      03-29
      回复
    • 朔
      03-29回复简|ω・)°
      好嘞感谢大佬
      03-29
      回复
登录 后发表内容