即使在阅读了关于这个主题的所有SO帖子之后,也很难解决这个问题,但是这一点很难实现.
我安装了org.apache.cordova.whitelist插件,我在index.html文件中添加了Content-Security-Policy元指令,并在config.xml中添加了相应的和标签.但是,每次我运行应用程序(Android)时都会收到以下错误:
“No Content-Security-Policy Meta tag found. Please add one when using
the cordova-plugin-whitelist plugin.”,source:
file:///android_asset/www/plugins/cordova-plugin-whitelist/whitelist.js
这是非常基本的索引页面:
required by applicable law or agreed to in writing,software distributed under the License is distributed on an
"AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND,either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
Meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src: 'self' 'unsafe-inline' 'unsafe-eval'" />
<Meta charset="utf-8" />
<Meta name="format-detection" content="telephone=no" />
<Meta name="msapplication-tap-highlight" content="no" />
<Meta name="viewport" content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width,height=device-height,target-densitydpi=device-dpi" />
这是config.xml:
最佳答案
仅用于测试目的:注释掉这一行 – >
< meta http-equiv =“Content-Security-Policy”content =“default-src *; style-src'self''unsafe-inline'; script-src:'self''unsafe-inline''unsafe-eval '“/>
比你的问题消失了.
您可以在此处找到有关白名单的其他信息:Cordova Plugin – Whitelist