我正在通过powerbi js Embedded(ajax)将powerbi报表嵌入到我的页面中,但是在从powerbi报表获取页面时遇到了问题。
我已经尝试过.load方法,report.getPages()会引发此错误:
ERROR Error: Uncaught (in promise): Object: {"data":"","status":401,"activityId":"xxx","requestId":"yyy","responseRequestId":null,"pendingRequestCount":0}
我的JS是这样的:
tab == null ? 0 : tab;
// call load() instead of embed() to load the report while delaying the rendering process
var report = powerbi.load(embedContainer, config);
// when loaded event occurs, set current page then call render()
report.on("loaded", function () {
console.log("loaded event executing");
// call to get Pages collection
report.getPages().then(
function (pages) {
// inspect pages in browser console
console.log(pages);
// display specific page in report
var startPage = pages[1]; // this selects the second page
config.pageName = startPage.name;
// Call report.render() to display report
report.render(config);
});
});
我希望报表的加载在页面呈现之前,而不是在页面呈现之后。
答案 0 :(得分:0)
这是一种解决方法,
var embedContainer = $(embedid)[0];
var report = powerbi.embed(embedContainer, config);
if(tab != null) {
report.on('loaded', function () {
report.getPages().then(function (pages) {
pages[tab].setActive();
});
});
}
但报告的第一页还是显示
。