微信小程序使用wx.showtoast后面代码不执行

if (res.statusCode === 200) {
                wx.showToast({
                    title: '保存成功',
                })
                console.log('保存成功')
                console.log('重新获取数据')
                console.log(res.data.bx_id)
                this.searchBx(res.data.bx_id)
            }

原来代码

this.searchBx(res.data.bx_id)没有执行



修改后:

if (res.statusCode === 200) {
                var that = this
                wx.showToast({
                    title: '保存成功',
                    success() {
                        console.log('保存成功')
                        console.log('重新获取数据')
                        console.log(res.data.bx_id)
                        that.searchBx(res.data.bx_id)
                    }
                })
            }

顺利执行


介绍:

 wx.showToast({
       title:"成功",
       icon: 'loading...',//图标,支持"success"、"loading" 
       image: '/images/tan.png',//自定义图标的本地路径,image 的优先级高于 icon
       duration: 2000,//提示的延迟时间,单位毫秒,默认:1500 
       mask: false,//是否显示透明蒙层,防止触摸穿透,默认:false 
       success:function(){},
       fail:function(){},
       complete:function(){}
     })
  },

猜你喜欢

转载自www.cnblogs.com/xia-feng/p/12672372.html