复制剪切板
需要先引入相关的CSS和JS文件:
<link rel="stylesheet" type="text/css" href="static/css/aui.min.css"/>
<script src="static/js/aui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/jquery/jquery-2.1.3.min.js" type="text/javascript" charset="utf-8"></script>
示例代码
<div class="container" id="app">
<header class="aui-header">
<a class="aui-header-left" onclick="aui.closeWin()"><i class="iconfont iconreturn"></i></a>
<div class="aui-header-title">复制到剪贴板</div>
</header>
<div class="content" style="padding: 15px 15px 0 15px;">
<div class="clipboard-warp">
<div id="text" class="border">
<input type="text" name="" id="copytext" placeholder="请输入文字内容" value="" />
</div>
<div class="aui-btn copy-btn" onclick="copy()"><i class="iconfont iconcopy"></i><span>复制</span></div>
</div>
</div>
</div>
<script type="text/javascript">
function copy() {
var _this = this;
if(!aui.isDefine(_this.text)){aui.toast({msg: '请输入文字内容'}); return;}
aui.copy(_this.text);
aui.toast({msg: '复制成功'});
}
</script>