拒绝加载脚本 'architect://architect.js'

Refused to load the script 'architect://architect.js'

这里的解决方案似乎有问题 link 所以我又发布了一个

Can't load my world, issue with loading architect://architect.js

您好,我正在为如何加载

而苦恼

architect.js

在我的 cordova android 项目中使用 wikitude cordova 插件,因为它一直在显示

Refused to load the script 'architect://architect.js' because it violates the following Content Security Policy directive: "script-src * 'unsafe-inline' 'unsafe-eval'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

这里是关于如何添加 architect.js

的文档

https://www.wikitude.com/external/doc/documentation/latest/phonegap/samples.html#including-architectjs-prior-to-wikitude-sdk-53

这是我的代码

index.html

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * 'unsafe-inline';">
    <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">
    <link rel="stylesheet" type="text/css" href="css/index.css">
    <script src="architect://architect.js"></script>
    <title>Hello World</title>
</head>
<body>
    <button onclick="app.fight()" style="width:30%;height:30%;font-size: 30px; margin-top: 40%; margin-left: 30%">Camera</button>

    <textarea id="fem"></textarea>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
</body>

index.js

var app = {

// Url/Path to the augmented reality experience you would like to load
arExperienceUrl: "www/index.html",
// The features your augmented reality experience requires, only define the ones you really need
requiredFeatures: [ "image_tracking"],
// Represents the device capability of launching augmented reality experiences with specific features
isDeviceSupported: false,
// Additional startup settings, for now the only setting available is camera_position (back|front)
startupConfiguration:
{
    "camera_position": "back"
},
// Application Constructor
initialize: function() {
    this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
onDeviceReady: function() {
    app.wikitudePlugin = cordova.require("com.wikitude.phonegap.WikitudePlugin.WikitudePlugin");
    app.wikitudePlugin.isDeviceSupported(app.onDeviceSupported, app.onDeviceNotSupported, app.requiredFeatures);
},
// Callback if the device supports all required features
onDeviceSupported: function() {

    app.wikitudePlugin.loadARchitectWorld(
        app.onARExperienceLoadedSuccessful,
        app.onARExperienceLoadError,
        app.arExperienceUrl,
        app.requiredFeatures,
        app.startupConfiguration
    );
},
// Callback if the device does not support all required features
onDeviceNotSupported: function(errorMessage) {
  alert("Device not supported"+ errorMessage);
},
// Callback if your AR experience loaded successful
onARExperienceLoadedSuccessful: function(loadedURL) {
    /* Respond to successful augmented reality experience loading if you need to */
    alert(AR);
},
// Callback if your AR experience did not load successful
onARExperienceLoadError: function(errorMessage) {
    alert(errorMessage);
}
};

app.initialize();

如果您使用任何高于 5.3 的 Wikitude SDK 版本,您必须使用

<script src="https://www.wikitude.com/libs/architect.js"></script>

documentation 中所述。