企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
#### 第一中: > 注意:第一种在微信里面的wap页面无效,是什么原因我不知道,,所以使用第二种 ~~~ textCopy(t) { const that = this // 如果当前浏览器版本不兼容navigator.clipboard if (!navigator.clipboard) { var ele = document.createElement("input"); ele.value = t; document.body.appendChild(ele); ele.select(); document.execCommand("copy"); document.body.removeChild(ele); if (document.execCommand("copy")) { that.$message({message: 'كۆچۈرۈش تامام', type: 'success'}); } else { that.$message({message: 'كۆچۈرۈش تامام', type: 'success'}); } } else { navigator.clipboard.writeText(t).then(function () { that.$message({message: 'كۆچۈرۈش تامام', type: 'success'}); }).catch(function () { that.$message({message: 'كۆچۈرۈش تامام', type: 'success'}); }) } } ~~~ #### 第二中: ``` npm install clipboard --save ``` 或者使用 CDN: ~~~html <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.10/dist/clipboard.min.js"></script> ~~~ html: ~~~ <div data-clipboard-text="哈哈哈哈" class="copy_text">点击复制</div> ~~~ js: ~~~ copyInit(){ var clipboard = new Clipboard('.copy_text'); clipboard.on('success', function (e) { Toast('كۆچۈرۈش تامام'); e.clearSelection(); }); clipboard.on('error', function (e) { Toast('失败x1'); }); } ~~~