解决 iframe 中不能使用 Clipboard API 的问题


当在 iframe 中使用 Clipboard API 是时候会报下面的错误

The Clipboard API has been blocked because of a permissions policy applied to the current document


导致问题的原因是 iframe 的 CSP 安全机制,解决办法通过 allow 属性明确告知我们需要的权限,见下面的代码