TypeError: Cannot set property ‘form‘ of undefined

TypeError: Cannot set property ‘form’ of undefined

1、data中未定义
2、

     uni.showModal({
    
    
	        title: "提示",
	        content: "上传成功",
	        showCancel: false,
	        success: function (res) {
    
    
				console.log(this);//undefined
	          if (res.confirm) {
    
    
				  that.image="";
				  that.form="";
	          }
	        },
	      });

以上代码中打印的this不是全局的,需要在外层增加 var that=this;
(若有错误请在评论区指正)

猜你喜欢

转载自blog.csdn.net/L221545/article/details/125625096
今日推荐