js 实现-复制内容到剪贴板

js 实现-复制内容到剪贴板_第1张图片
代码如下自取:

	if (url) {
	      const input = document.createElement( 'input' );
	      document.body.appendChild(input);
	      input.setAttribute('value' , url);
	      // input.setAttribute('value' , '我将会被你放到剪贴板上');
	      input.select();
	      if (document.execCommand('copy')) {
	          document.execCommand('copy');
	          this.$message.success('复制成功')
	      }
	      document.body.removeChild(input)
	  }

你可能感兴趣的:(备忘录,javascript,前端,开发语言)