uni-app uni.setClipboardData执行成功后再执行 uni.getClipboardData

实现逻辑,根据变量值来判断uni.setClipboardData是否执行

1. data里面定义变量state: false,

2. methods里面定义方法改变state状态。

handleClick () {
  var _this = this
  uni.setClipboardData({
	data: 'hello',
	success () {
	  _this.state = true;
	  console.log('success');
	}
  });
  console.log('点击成功!');
},
getClick () {
  if (this.state) {
	uni.getClipboardData({
	success: function (res) {
		console.log(res);
	  }
    });
  } else {
	console.log('没有执行!');
  }
}

  

posted @ 2020-01-14 17:59  本溢  阅读(2721)  评论(0)    收藏  举报