瀏覽代碼

Merge pull request #159 from gclove/copy-button

随机密码生成器,增加复制按钮
Alien-阿烈叔 3 年之前
父節點
當前提交
8be73b6a73
共有 2 個文件被更改,包括 14 次插入0 次删除
  1. 0 0
      apps/password/index.html
  2. 14 0
      apps/password/index.js

文件差異過大導致無法顯示
+ 0 - 0
apps/password/index.html


+ 14 - 0
apps/password/index.js

@@ -41,6 +41,20 @@ new Vue({
 
         getResult: function () {
             this.$refs.rstCode.select();
+        },
+
+        copyResult: function () {
+            // 选中要复制的内容
+            this.getResult();
+
+            if ('clipboard' in navigator) {
+                navigator.clipboard.writeText(this.resultContent)
+                .catch(err => {
+                    console.error('复制失败: ', err);
+                });
+            }else{
+                alert("您的浏览器不支持 clipboard API, 请手动复制")
+            }
         }
     }
 });

部分文件因文件數量過多而無法顯示