1. 程式人生 > >小程序點擊復制如何實現

小程序點擊復制如何實現

family 一鍵 來源 cancel http table else mod self.

?

wx.setClipboardData({

data: ‘data‘,

success: function(res) {

wx.getClipboardData({

success: function(res) {

console.log(res.data) // data

}

})

}

})

?

將要復制的內容放到data裏面即可。

?

?

獲取系統剪貼板的內容

wx.getClipboardData({

  success: function(res){


					console.log(res.data)

  }

})
					

?

?

Demo:

<text class="tblin_items_txt" selectable="true">{{detail.taokouling||‘‘}}</text> <!-- 復制的對象-->

<view class="tblin_items_btn" bindtap="copyTBL">一鍵復制</view><!-- 復制操作 -->

?

Js:

copyTBL:function(e){

var self=this;

wx.setClipboardData({

data: self.data.taokouling,

success: function(res) {

// self.setData({copyTip:true}),

wx.showModal({

title: ‘提示‘,

content: ‘復制成功‘,

success: function(res) {

if (res.confirm) {

console.log(‘確定‘)

} else if (res.cancel) {

console.log(‘取消‘)

}

}

})

}

});

}

文章來源:劉俊濤的博客

歡迎關註,有問題一起學習歡迎留言、評論。

小程序點擊復制如何實現