多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## Copy 复制到剪贴板 复制文本到剪贴板 ![](https://img.kancloud.cn/2e/a5/2ea571835bd452011ba97a1bbea48d88_1083x93.png =600x) ### 代码示例 ```javascript <template> <div class="page"> <cvu-row :gutter="16"> <cvu-col span="10"><Input v-model="copyText" placeholder="请输入文本内容" clearable></Input></cvu-col> <cvu-col span="5"><cvu-button type="primary" @on-click="handleClick">复制到剪贴板</cvu-button></cvu-col> </cvu-row> </div> </template> <script> export default { data() { return { copyText: '' } }, methods: { handleClick() { if(!this.copyText) { this.$Message.warning('请输入文本内容') return } this.$cvuCopy({ text: this.copyText }).then(() => { this.$Message.success('复制成功') }) } } } </script> <style lang="scss" scoped> .page{ height: 100%; padding: 15px; box-sizing: border-box; h3{ margin: 10px 0; } /deep/.ivu-input{ height: 40px; line-height: 40px; } } </style> ``` ### methods >[success] `this.$cvuCopy(options)` - options: - text:文本内容