如何利用修改下面这段代码(以下页面中的code)以直接生成一个单独的页面?
https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/#// Read embed application token from textbox
var txtAccessToken = $('#txtAccessToken').val();
 
// Read embed URL from textbox
var txtEmbedUrl = $('#txtReportEmbed').val();
 
// Read report Id from textbox
var txtEmbedReportId = $('#txtEmbedReportId').val();
 
// Read embed type from radio
var tokenType = $('input:radio[name=tokenType]:checked').val();
 
// Get models. models contains enums that can be used.
var models = window['powerbi-client'].models;
 
// We give All permissions to demonstrate switching between View and Edit mode and saving report.
var permissions = models.Permissions.All;
 
// Embed configuration used to describe the what and how to embed.
// This object is used when calling powerbi.embed.
// This also includes settings and options such as filters.
// You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
var config= {
    type: 'report',
    tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
    accessToken: txtAccessToken,
    embedUrl: txtEmbedUrl,
    id: txtEmbedReportId,
    permissions: permissions,
    settings: {
        filterPaneEnabled: true,
        navContentPaneEnabled: true
    }
};
 
// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];
 
// Embed the report and display it within the div container.
var report = powerbi.embed(embedContainer, 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');
     }
 });

解决方案 »

  1.   

    <div id="embedContainer"></div>
    <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"></script>
    <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js"></script>
    <script>
    var txtAccessToken = 'H4sIAAAAAAAEAB2WxQ70CA6E3-W_ZqQwjTSHMHWYc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ODvT_bmyER3wClA5dB_HeW8ql-7PR4WMPxxbOXP7Owtr5G4b_kcK94CLlBvnA07ArGlwWN1FKgv7iW3Y8Nxqky2GuXQ9I8TUKfaZ0wFNSvje-N6BKk2noBColoVxTLHYSZ_-SxDCVz25nOHsn1me0HREsUC7zuzxJLib4kQMwxYgT7jYHw997qa2HUVTIs33_M4RtzjafddcLn-Xh_zGCV5kFu3zr1x6PLmrjDPY59F4SQ0Sh9iZehHIaL0sQV6c9ELPjN7AEnj8rYVfH0QSUewztXTANQ6TveF-CPVaq8u3okZ59HVEYRQ-ZvRdV0kLsE88-_Mj9LU36V4KfyccwO0_UpnyfWdo-SieKsaP9b5bb1lO7Ht_yVJcm5ekGjB2BRYbIemsoIJ6gikOYB-NkVpsmSIL4-P1mkoDyanbuC-T-E8rmZKox3e0fqyrMgbIRegS-uEqMfAyJ4Lu0SHnAqCSDxQVWAgkuSH1bhgSDJlNjrG7FzYbtFntzbyJ8xkFodEixQhpbNW2CcucLH4HYIGzmH7d-ulWHlXr06h1KbNUD4tmantyc1M398H3WI3O45y_Z8DgvfYCW8iICLsMmuVsySRzULzl-9WULpsvctnbDjNzdfNWbbrwuCmQx9vhM4bUo1kann7KK-DDTjJVmRo69GIFflxLvkz8kBUUSq7W7AkoVubgllbAEc8JioXi-CE7NQ31JDsfn_l_Hf_wGAArM0LgsAAA==';
     
    // Read embed URL from textbox
    var txtEmbedUrl = 'https://app.powerbi.com/reportEmbed?reportId=bac25fa7-d58d-40b6-8b01-606d165c3b43&groupId=be8908da-da25-452e-b220-163f52476cdd';
     
    // Read report Id from textbox
    var txtEmbedReportId = 'bac25fa7-d58d-40b6-8b01-606d165c3b43';
     
    // Read embed type from radio
    var tokenType = 1;
     
    // Get models. models contains enums that can be used.
    var models = window['powerbi-client'].models;
     
    // We give All permissions to demonstrate switching between View and Edit mode and saving report.
    var permissions = models.Permissions.All;
     
    // Embed configuration used to describe the what and how to embed.
    // This object is used when calling powerbi.embed.
    // This also includes settings and options such as filters.
    // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
    var config= {
        type: 'report',
        tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
        accessToken: txtAccessToken,
        embedUrl: txtEmbedUrl,
        id: txtEmbedReportId,
        permissions: permissions,
        settings: {
            filterPaneEnabled: true,
            navContentPaneEnabled: true
        }
    };
     
    // Get a reference to the embedded report HTML element
    var embedContainer = $('#embedContainer')[0];
     
    // Embed the report and display it within the div container.
    var report = powerbi.embed(embedContainer, 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() {
        console.log("Loaded");
    });
     
    report.on("error", function(event) {
        console.log(event.detail);
     
        report.off("error");
    });
     
    report.off("saved");
    report.on("saved", function(event) {
        console.log(event.detail);
        if(event.detail.saveAs) {
            console.log('In order to interact with the new report, create a new token and load the new report');
         }
     });</script>
      

  2.   

    首先非常感谢您能回答我的问题!
    我将代码存为一个html文件,打开后提示“无法查看此内容。详细了解 Power BI。”
    不知问题出在哪里呢?
      

  3.   

    token过期了
      

  4.   

    如果是过期,为什么这个示例页面还能用呢?
    https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html#
      

  5.   

    它token变新的了啊
      

  6.   

    也就是这个token是变化的,需要动态获取到,对吧?