實現邏輯,根據變量值來判斷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('沒有執行!');
}
}
