search

Home  >  Q&A  >  body text

How to add a button to copy displayed text in vue.js?

I'm trying to add a button that will allow me to copy a snippet of code from a view to the clipboard of my code catalog application in vue.js.

When I use the vue clipboard library and try to do this in the example component:

<div class="full-screen-code-snippet">
  {{ example.codeSnippet }}
</div>

<div class="full-screen-copy-button">
<button v-clipboard:copy="example.codeSnippet"></button>    
</div>

The code snippet displays normally, but the button does not display. How is this going? How should I make this button?

P粉297434909P粉297434909241 days ago455

reply all(1)I'll reply

  • P粉509383150

    P粉5093831502024-03-29 09:55:40

    You should use it like this: v-clipboard="variableName" or the same as :copy. You can here or this

    
    
    sssccc

    reply
    0
  • Cancelreply