微信小程序的点击复制功能
生活随笔
收集整理的這篇文章主要介紹了
微信小程序的点击复制功能
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
wxml如下:
<view class="b-button" bindtap='copyUrl' data-id="www.baidu.com"><view class="f-30 xzsd">點擊復(fù)制網(wǎng)址</view> </view>js如下:
// 點擊復(fù)制事件 copyUrl: function (e) {// console.log(e.currentTarget.dataset.id)if(e.currentTarget.dataset.id == null){wx.showToast ({title: '暫無url數(shù)據(jù)!',icon: 'none',duration: 2000,});}else{//復(fù)制的方法wx.setClipboardData({//要復(fù)制的數(shù)據(jù)data: e.currentTarget.dataset.id,success: function (res) {wx.showToast ({title: '網(wǎng)址復(fù)制成功,請前往瀏覽器粘貼打開!',icon: 'none',duration: 2000,});}});} },?
參考自:https://www.cnblogs.com/joe235/p/13321080.html?utm_source=tuicool
總結(jié)
以上是生活随笔為你收集整理的微信小程序的点击复制功能的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信小程序把wx.showToast的文
- 下一篇: 解放军院士人数