<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="./conmon.css"> <link rel="stylesheet" href="./index.css"> </head> <body> <div id="app"> <div class="wrapper"> <div class="modalBtn">复制成功</div> <div class="content"> <h1 class="title">账号密码:</h1> <div class="box" v-for="(item,index) in info" :key="index"> <h4 class="name">{{item.name}}</h4> <div class="item bss" @click="copy1" :id="item.bssid">{{item.bss}}</div> <div class="item pss" @click="copy2" :id="item.pssid">{{item.pss}}</div> </div> </div> </div> </div> </body> </html> <script src="https://unpkg.com/vue@3"></script> <script> const { createApp } = Vue createApp({ data() { return { message: 'Hello Vue!', info: [{ bssid: '1554523687', pssid: 'abcde666', status: 1, name: '4399', bss: '1554523687', pss: 'abcde666', }, { bssid: '1609001254557', pssid: 'xhi11asj12sjKA', status: 1, name: '华为帐号', bss: '1609001254557', pss: 'xhi11asj12sjKA#xx', }, ] } }, methods: { copy1(e) { this.copyFunc(e.srcElement.id) }, copy2(e) { this.copyFunc(e.srcElement.id) }, copyFunc(e) { const range = document.createRange(); // 创建range对象 range.selectNode(document.getElementById(e)); //获取复制内容的 id 选择器 const selection = window.getSelection(); //创建 selection对象 if (selection.rangeCount > 0) selection .removeAllRanges(); //如果页面已经有选取了的话,会自动删除这个选区,没有选区的话,会把这个选取加入选区 selection.addRange(range); //将range对象添加到selection选区当中,会高亮文本块 document.execCommand('copy'); //复制选中的文字到剪贴板 selection.removeRange(range); // 移除选中的元素 var modalBtn = document.getElementsByClassName('modalBtn')[0]; modalBtn.style.display = "block"; setTimeout(() => { modalBtn.style.display = "none"; }, 1000); } } }).mount('#app') </script>/* common.css 清除浏览器默认样式 */
/** * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/) * http://cssreset.com */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, menu, nav, output, ruby, section, summary, time, mark, audio, video, input { margin: 0; padding: 0; border: 0; font-size: 100%; font-weight: normal; vertical-align: baseline; } /* HTML5 display-role reset for older browsers */ article, aside, details, figcaption, figure, footer, header, menu, nav, section { display: block; } body { line-height: 1; } blockquote, q { quotes: none; } blockquote:before, blockquote:after, q:before, q:after { content: none; } table { border-collapse: collapse; border-spacing: 0; } /* custom */ a { color: #7e8c8d; text-decoration: none; -webkit-backface-visibility: hidden; } li { list-style: none; } ::-webkit-scrollbar { width: 5px; height: 5px; } ::-webkit-scrollbar-track-piece { background-color: rgba(0, 0, 0, 0.2); -webkit-border-radius: 6px; } ::-webkit-scrollbar-thumb:vertical { height: 5px; background-color: rgba(125, 125, 125, 0.7); -webkit-border-radius: 6px; } ::-webkit-scrollbar-thumb:horizontal { width: 5px; background-color: rgba(125, 125, 125, 0.7); -webkit-border-radius: 6px; } html, body { width: 100%; } body { -webkit-text-size-adjust: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } html { height: 100%; width: 100%; background: #f3f3f3; }
/* index.css */标签:插件,vue,color,none,js,selection,background,webkit,border From: https://www.cnblogs.com/iuniko/p/16649672.html
html { background-color: #f2f2f2; } .wrapper { width: 568px; margin: 0 auto; background-color: #1890ff; position: relative; color: #fff; } .content { padding: 16px; } .box { margin-top: 16px; position: relative; } .title { margin-bottom: 32px; } .modalBtn { padding: 6px 12px; background-color: rgba(0, 0, 0, 0.8); color: #fff; margin: auto; position: absolute; left: 0; right: 0; bottom: 0; top: 0; display: none; z-index: 100; width: 100px; height: 44px; border-radius: 16px; line-height: 44px; text-align: center; } .item { display: flex; justify-content: space-between; margin-bottom: 16px; align-items: center; border: 1px solid #1890ff; padding: 10px; border-radius: 4px; cursor: pointer; background: #fff; color: #000; } h1 { font-size: 32px; font-weight: 600; } h4 { font-size: 16px; font-weight: 600; } .name { margin-bottom: 16px; } .copy { position: absolute; right: 6px; padding: 6px 12px; background-color: #1890ff; color: #fff; border-radius: 4px; cursor: pointer; } .top1 { top: 37px; } .top2 { top: 91px; }