代码之家  ›  专栏  ›  技术社区  ›  rschpdr

当由javascript api呈现时,powerbi嵌入报告在加载时挂起。

  •  0
  • rschpdr  · 技术社区  · 6 年前

    我正在尝试将一个powerbi报告嵌入到我的web应用程序中,这个程序在我的dev服务器上本地运行,带有javascript api。我知道一切都在工作,因为我在他们的 Playground 因此,它不可能是嵌入式服务器或Azure的问题。在我的控制台窗口中,有多个外部资源的警告和错误被同一源策略阻止,并且 uncaught exception: [object Object] 错误可能与无法破译的PBI JavaScript API有关。该报告只是永远加载,显示动画的powerbi徽标。尝试在本地嵌入报表时是否有其他人遇到此问题?下面是负责呈现的代码:

    var embedContainer = $("#container");
    var models = window.['powerbi-client'].models;
    
        var config= {
            type: 'report',
            tokenType: models.TokenType.Embed,
            accessToken: ginormous embed token,
            embedUrl: https://app.powerbi.com/reportEmbed?reportId=ommited_for_privacy&groupId=ommited_for_privacy,
            id: the_report_id,
            permissions: models.Permissions.All,
            settings: {
                    filterPaneEnabled: true,
                    navContentPaneEnabled: true
            }
        };
    
        // Embed the report and display it within the div container.
        var report = powerbi.embed(embedContainer.get(0), config);
    
        // Report.off removes a given event handler if it exists.
        report.off("loaded");
    
        // Report.on will add an event handler which prints to Log window.
        report.on("loaded", function() {
            Log.logText("Loaded");
        });
    
        report.on("error", function(event) {
            Log.log(event.detail);
    
            report.off("error");
        });
    
        report.off("saved");
        report.on("saved", function(event) {
            Log.log(event.detail);
            if(event.detail.saveAs) {
                    Log.logText('In order to interact with the new report, create a new token and load the new report');
            }
        });
    

    以下是所有控制台错误:

    uncaught exception: [object Object]
    
    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://dc.services.visualstudio.com/v2/track. (Reason: CORS request did not succeed).
    
    Source map error: request failed with status 404
    Resource URL: http://localhost:3000/temp/scripts/App.js
    
    Source Map URL: powerbi.js.map
    Source map error: request failed with status 404
    Resource URL: https://app.powerbi.com/13.0.5314.162/scripts/ai.0.js
    
    Source Map URL: ai.0.js.map
    Source map error: request failed with status 404
    Resource URL: https://app.powerbi.com/13.0.5314.162/scripts/reportembed.externals.bundle.min.js
    
    Source Map URL: interact.min.js.map
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   rschpdr    6 年前

    我的坏人。

    问题是,火狐没有显示异常的原因,但Chrome显示了。我应该在询问之前在另一个浏览器中进行测试。有了异常文本,我可以将问题跟踪到 tokenType 参数和它工作得很好。