【发布时间】:2019-09-14 19:07:44
【问题描述】:
我们如何在 NodeJs 中使用 express handlebar 模板实现复制到剪贴板功能。
我尝试过使用 Javascript,但它不起作用。
下面是我试过的代码:
myFile.handlebars:
<input type="button" id="linkBtn" class="btn btn-primary" onclick="copyLink()" data-toggle="tooltip" title="Copy to Clipboard" value="copy link" readonly />
<script>
function copyLink() {
let copyText = document.getElementById("linkBtn");
/* Select the text field */
copyText.select();
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
//alert("Copied the text: " + copyText.value);
}
</script>
【问题讨论】:
标签: javascript node.js express-handlebars