且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Cordova - 拒绝执行内联事件处理程序,因为它违反了以下内容安全策略

更新时间:2022-04-19 22:47:08

选中此链接 https://developer.chrome.com/extensions/contentSecurityPolicy 它说:


内联JavaScript不会执行。此限制禁止内联块和内联事件处理程序(例如button onclick =...)。

Inline JavaScript will not be executed. This restriction bans both inline blocks and inline event handlers (e.g. button onclick="...").

(click,capturePhoto)中的简单事件监听器,例如:

So you can use a simple event listener inside a script tag like:

document.getElementById("myBtn").addEventListener("click", capturePhoto);