在 React JS 中嵌入 Power BI 报表以获取报表实例

Embed a Power BI report in React JS to get report instance(在 React JS 中嵌入 Power BI 报表以获取报表实例)
本文介绍了在 React JS 中嵌入 Power BI 报表以获取报表实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试在 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 报表以获取报表实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
Ordinals in words javascript(javascript中的序数)