问题描述
我正在尝试在 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设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)