1.復制功能可以參照官方文檔,
copytext: function() {
var that = this;
wx.setClipboardData({
data: that.data.shareresult.content,
success: function(res) {
if (res.confirm) {
console.log('確定')
} else if (res.cancel) {
console.log('取消')
}
}
});
},
2.背景顏色漸變實現
-->wxml
<view class='copyBtn' bindtap="copytext">復制文字</view>
-->wxss
background: linear-gradient(to right, #3d6aea, #7318d9);/
.copyBtn {
margin: 35rpx auto;
width: 240rpx;
height: 60rpx;
text-align: center;
line-height: 60rpx;
border-radius: 30rpx;
color: #fff;
background: linear-gradient(to right, #3d6aea, #7318d9);//使用linear-gradient 指定方向(to right/to left) 以逗號分割 兩側不同的顏色
}
