mui 把内容复制到剪切板

function copyShareUrl(){
mui.plusReady(function(){
//复制链接到剪切板
var copy_content = "";
//判断是安卓还是ios
if(mui.os.ios){
//ios
var UIPasteboard = plus.ios.importClass("UIPasteboard");
    var generalPasteboard = UIPasteboard.generalPasteboard();
    //设置/获取文本内容:
    generalPasteboard.plusCallMethod({
        setValue:copy_content,
        forPasteboardType: "public.utf8-plain-text"
    });
    generalPasteboard.plusCallMethod({
        valueForPasteboardType: "public.utf8-plain-text"
    });
}else{
//安卓
var context = plus.android.importClass("android.content.Context");
  var main = plus.android.runtimeMainActivity();
  var clip = main.getSystemService(context.CLIPBOARD_SERVICE);
  plus.android.invoke(clip,"setText",copy_content);
}
});
}

 

posted @ 2018-09-12 16:49  Duan?  阅读(1825)  评论(0编辑  收藏  举报