copyText.vue 661 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <text class="copyText" @click="copyText">复制</text>
  3. </template>
  4. <script>
  5. import clipboard from "@/js_sdk/dc-clipboard/clipboard.js"
  6. export default{
  7. props:{
  8. text: {
  9. type: String,
  10. default: ''
  11. },
  12. label: {
  13. type: String,
  14. default: ''
  15. },
  16. },
  17. methods:{
  18. // 复制
  19. copyText(){
  20. clipboard.setText(this.text);
  21. uni.showToast({
  22. icon: 'none',
  23. title: this.label + '已复制成功'
  24. })
  25. },
  26. }
  27. }
  28. </script>
  29. <style>
  30. .copyText{
  31. font-size: 20upx;
  32. color:#333;
  33. margin-left: 20upx;
  34. background: #c1c1bf;
  35. font-weight: normal;
  36. padding: 0 5upx;
  37. border-radius: 5upx;
  38. color: #fff;
  39. }
  40. </style>