开发cordova过程中,遇到真机调试问题。
在4.4手机上运行cordova工程可以运行成功,而且功能都能使用,但是换成5.0以上的手机后,出现下面报错
"Refused to execute inline event handler because it violates the following Content Security Policy directive: "default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
有两种方法可以解决,下面是具体的例子:
1.是通过将HTML里面的文件方法直接以回调方式写出来。
参考下面链接:https://stackoverflow.com/questions/31060722/cordova-refuse-to-execute-inline-event-handler-because-it-violates-the-followi
2.是直接将html里面的meta代码注释掉
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> 注释掉此行代码即可运行调试。