clipBoard,这个是剪贴板模块,可以管理剪贴板。当然,如果不用的话,也可以用js的方法,可以查看js复制到剪贴板。废话不多说,查看代码:html代码:
<div class="message_voice" @touchstart="onTouchStart('我是要复制的内容')" @touchmove="onTouchMove" @touchend="onTouchEnd">
我是要复制的内容
</div>
js代码:
data:{
touchStartTime:0,
touchDuration:0,
recordTimer:null,
},
methods:{
//长按复制
onTouchStart(txt){
var that = this;
this.touchStartTime = new Date().getTime();
clearInterval(that.recordTimer);
that.recordTimer = setInterval(function(){
that.touchDuration = new Date().getTime() - that.touchStartTime;
if(that.touchDuration > 800){
var clipBoard = api.require('clipBoard');
clipBoard.set({
value: txt
}, function(ret, err) {
if (ret) {
func.msg('复制成功,去粘贴吧!');
}
});
clearInterval(that.recordTimer);
}
},200)
},
onTouchMove(){
var that = this;
clearInterval(that.recordTimer);
},
onTouchEnd(){
var that = this;
clearInterval(that.recordTimer);
},
} 