@@ -10,7 +10,7 @@ const props = defineProps({
1010 type: String ,
1111 default: ' console.log(' ,
1212 required: true ,
13- }
13+ },
1414})
1515const copy = (event ) => {
1616 getContent ()
@@ -20,22 +20,25 @@ const copy = (event) => {
2020const textarea = ref (null )
2121const getContent = () => {
2222 let textArea = textarea .value
23- console .log (textArea,' textArea' )
23+ console .log (textArea, ' textArea' )
2424 if (document .execCommand (' copy' ) == true ) {
25+ console .log (' document.execCommandtrue' )
2526 // older browser support
2627 let range, selection
2728 textArea .focus ()
2829 textArea .select ()
2930 range = document .createRange ()
3031 range .selectNodeContents (textArea)
32+ console .log (range, ' range' )
3133 selection = window .getSelection ()
3234 selection .removeAllRanges ()
3335 selection .addRange (range)
3436 textArea .setSelectionRange (0 , textArea .value .length )
3537 document .execCommand (' copy' )
3638 } else {
3739 // modern browser support (using the clipboard API)
38- navigator .clipboard .writeText (textArea .value )
40+ console .log (' navigator.clipboard.writeText(textArea.value)' )
41+ navigator .clipboard .writeText (props .codeValue )
3942 }
4043}
4144 </script >
@@ -44,7 +47,12 @@ const getContent = () => {
4447 <!-- <input type="text" /> -->
4548 <div class =" cb" tabindex =" 0" @focusout =" resetMessage" @click =" copy" >
4649 <!-- <div class="cb_tooltip">{{ Tips }}</div> -->
47- <textarea ref =" textarea" :value =" props.codeValue" tabindex =" 1" readonly ></textarea >
50+ <textarea
51+ ref =" textarea"
52+ :value =" props.codeValue"
53+ tabindex =" 1"
54+ readonly
55+ ></textarea >
4856 <div class =" cb_copy" >{{ text }}</div >
4957 <!-- <div v-show='copyjudge' class="cb_copy">copied</div> -->
5058 </div >
0 commit comments