我正在尝试在 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模板网!
discord.js v12:我如何等待 DM 频道中的消息?discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 频道中的消息?)
如何让我的机器人提及发出该机器人命令的人how to make my bot mention the person who gave that bot command(如何让我的机器人提及发出该机器人命令的人)
如何修复必须使用导入来加载 ES 模块 discord.jsHow to fix Must use import to load ES Module discord.js(如何修复必须使用导入来加载 ES 模块 discord.js)
如何列出来自特定服务器的所有成员?How to list all members from a specific server?(如何列出来自特定服务器的所有成员?)
Discord bot:修复“找不到 FFMPEG"Discord bot: Fix ‘FFMPEG not found’(Discord bot:修复“找不到 FFMPEG)
使用 discord.js 加入 discord 服务器时的欢迎消息Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服务器时的欢迎消息)