Answers for "vue clipboard example"

1

vue js copy text to clipboard

methods: {
    copyURL() {
      var Url = this.$refs.mylink;
      Url.innerHTML = window.location.href;
      console.log(Url.innerHTML)
      Url.select();
      document.execCommand("copy");
    }
  }
Posted by: Guest on July-30-2021
0

vue clipboard example

<button @click.prevent="handlerCopyText">
						<input id="copyText" v-model="copyMessage" type="hidden" />
						<img src="~/assets/svg/copy-link.svg" alt="" srcset="" class="object-contain max-h-10 mx-auto" />
						<div class="text-center text-sm text-gray-900">Salin tautan</div>
					</button>

<script>
  
  handlerCopyText() {
				const copyText = document.querySelector('#copyText')
				copyText.setAttribute('type', 'text')
				copyText.select()

				const successful = document.execCommand('copy')

				if (successful) {
					this.copySuccess = successful
					this.copyMessage = `${window.location.href}`
					setTimeout(() => {
						this.copySuccess = false
					}, 800)
				}

				copyText.setAttribute('type', 'hidden')
				window.getSelection().removeAllRanges()
			}
  
</script>
Posted by: Guest on September-22-2021

Browse Popular Code Answers by Language