#1,利用clipboard.min.js(https://github.com/zenorocha/clipboard.js/)这种兼容性比较好的方式实现。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>function-text</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-- 1. Define some markup -->
<button class="btn">Copy</button>
<!-- 2. Include library -->
<script src="http://cdnaliyun.oss-cn-hangzhou.aliyuncs.com/js/clipboard.min.js"></script>
<!-- 3. Instantiate clipboard -->
<script>
(function () { // 点击btn实现复制
var copy_text = "要复制的文字";
var clipboard = new ClipboardJS("