我正在尝试在 React JS 中嵌入 Power BI 报表,我想嵌入报表并让报表实例进一步使用它.我正在使用 Power BI 反应扩展来反应嵌入报告,但我不断收到无法读取未定义的属性嵌入"的错误.
I am trying to embed a Power BI report in React JS and I would like to embed the report and get the report instance to work further with it. I am using Power BI react extension in react to embed the report but I keep getting an error that Cannot read property 'embed' of undefined.
索引.js
import { powerbi, models, embed } from "powerbi-client";
import React, { useState, useEffect } from "react";
import ReactDOM from "react-dom";
function ReportBI() {
let token ="abcExample";
let embedUrlBi = "https://app.powerbi.com/reportEmbed";
let reportId = "ReportID";
const embedConfig = {
type: "report",
id: reportId,
embedUrl: embedUrlBi,
accessToken: token,
tokenType: models.TokenType.Embed
};
function test() {
var embedContainer = document.getElementById("container");
var report = powerbi.embed(embedContainer, embedConfig);
console.log(report);
}
useEffect(() => {
test();
});
return (
<>
<div id="container"></div>
</>
);
}
const element = <ReportBI />;
ReactDOM.render(element, document.getElementById("root"));
索引.Html
<div id="root">
<div id="container"></div>
</div>
我试图在嵌入报表后获取它的实例以使用它做其他事情.我可以这样做吗?
I am trying to get instance of the report after embedding it to do other things with it. Can I do this?
你可以试试新的 powerbi-client-react 用于在 React 应用程序中嵌入 PowerBI 实体的库
You may try the new powerbi-client-react library for embedding PowerBI entities in React applications
"getEmbeddedComponent"prop 返回嵌入式 PowerBI 报表的实例
The "getEmbeddedComponent" prop returns the instance of embedded PowerBI report
这篇关于在 React JS 中嵌入 Power BI 报表以获取报表实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!