代码之家  ›  专栏  ›  技术社区  ›  Renz Salanga

拒绝加载脚本“architect://architect.js”

  •  0
  • Renz Salanga  · 技术社区  · 6 年前

    这里的解决方案似乎有一个断开的链接,所以我发布了另一个

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

    你好,我正在努力装

    建筑设计师

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

    拒绝加载脚本“architect://architect.js”,因为它违反了以下内容安全策略指令:“script src*”unsafe inline“”unsafe eval“”。请注意,未显式设置“script-src-elem”,因此“script-src”用作回退。

    以下是有关如何添加architect.js的文档

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

    这是我的密码

    索引文件

    <!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>
    

    索引文件

    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();
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Someone    6 年前

    如果您使用的wikitude sdk版本高于5.3,则必须使用

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

    如中所述 documentation .