0

How can I copy the text by click the div in the render function?

in the bellow you can see the div, I want to click it, then the clipboard can copy the text of it.

my code of render function is bellow:

      h(
         'div',
         {slot:"content"},
         [
           h(
            'ul',
             params.row.ipv4s.map((item, index) => {
               return h('li', [h('span', {}, index + 1 + '. ' + item.ip)])

             })
           )
         ]
       )

how can I realize my requirement?

sof-03
  • 2,255
  • 4
  • 15
  • 33

1 Answers1

0

Perhaps this can help you out:

https://www.npmjs.com/package/clipboard

Tackling this yourself can be a pretty cumbersome task for something which should have been implemented with an API across all browsers but unfortunately isn't.

Stephan-v
  • 19,255
  • 31
  • 115
  • 201