实现逻辑,根据变量值来判断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('没有执行!'); } }