Safari clipboard error "TypeError: undefined is not an object"
Safari clipboard error "TypeError: undefined is not an object"
仅在 safari 浏览器中出现错误“TypeError: undefined is not an object (evaluating 'navigator.clipboard.writeText')”。我正在传递我当前的 link 。可能是什么问题呢?
copyLink = e => {
e.preventDefault();
console.log(document.location.href)
navigator.clipboard
.writeText(document.location.href)
.then(() => {
this.setState({
urlIsCopied: true
});
})
.catch(e => console.error(e));
};
你能看看插件吗copy-to-clipboard
。只需使用下面的代码即可。
copy('Text to Copy!');
希望对您有所帮助!
仅在 safari 浏览器中出现错误“TypeError: undefined is not an object (evaluating 'navigator.clipboard.writeText')”。我正在传递我当前的 link 。可能是什么问题呢?
copyLink = e => {
e.preventDefault();
console.log(document.location.href)
navigator.clipboard
.writeText(document.location.href)
.then(() => {
this.setState({
urlIsCopied: true
});
})
.catch(e => console.error(e));
};
你能看看插件吗copy-to-clipboard
。只需使用下面的代码即可。
copy('Text to Copy!');
希望对您有所帮助!