Browse Source

Merge pull request #159 from gclove/copy-button

随机密码生成器,增加复制按钮
Alien-阿烈叔 3 years ago
parent
commit
8be73b6a73
2 changed files with 14 additions and 0 deletions
  1. 0 0
      apps/password/index.html
  2. 14 0
      apps/password/index.js

File diff suppressed because it is too large
+ 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, 请手动复制")
+            }
         }
     }
 });

Some files were not shown because too many files changed in this diff