reactjs - 在 React 中嵌入 Power Bi 中捕获书签
问题描述
我正在尝试在我们的应用程序中实现书签捕获功能。我克隆了https://github.com/howlowck/react-powerbi库以使用此类功能对其进行扩展。基于 MS Demo 和文档,bookmarksManager 对象上有一个 .capture() 方法。这是我试图访问它的代码修改(这个库的文件 index.js):
componentDidUpdate () {
if (this.validateConfig(this.state)) {
this.embed(this.state)
console.log(this.component.bookmarksManager)
getBookmark(this.component)
}
}
...
function getBookmark(power){
console.log('inside getBookmark')
console.log(power.bookmarksManager.capture)
power.bookmarksManager.capture().then (function (capturedBookmark){
alert('inside callback')
});
console.log('passed test')
}
运行时 - console.log 显示“内部书签”也显示捕获功能,但从未执行回调。(也没有任何未捕获的承诺拒绝)任何有用的想法?
该函数存在于库中:
BookmarksManager.prototype.capture = function () {
if (utils.isRDLEmbed(this.config.embedUrl)) {
return Promise.reject(errors.APINotSupportedForRDLError);
}
return this.service.hpm.post("/report/bookmarks/capture", null, { uid: this.config.uniqueId }, this.iframe.contentWindow)
.then(function (response) { return response.body; }, function (response) {
throw response.body;
});
};
解决方案
在包括 powerbi.js 文件在内的彻底调试之后,似乎调用被提前并且配置为空,导致 { uid: this.config.uniqueId } 未定义。放置在组件下的相同函数将成功调用卸载。可能必须以接受回调作为道具的方式修改库。这个回调应该接受“power”对象。成功嵌入后,父组件可以捕获和/或在某些按钮操作上应用书签。
推荐阅读
- sql - 具有两个匹配结果的 SQL Server MERGE
- javascript - 如何在javascript中引用目录
- vb.net - 检查泛型类
- vba - VBA 宏:将工作表从一个 Excel 文件复制到另一个
- file-upload - 使用节点中的大型媒体文件一次发出多个发布请求时的内存问题
- c# - C# - 当用户滚动到富文本框的底部时如何显示一个复选框
- excel - 如何在 Excel 中将月份数字(即“12”)转换为月份名称?
- git - 清理 git 历史上的“WIP 和索引”
- bots - 制作机器人来填写 Troops.ai 对话框以更新销售人员记录,如何让我的机器人填写部队对话框?
- python - 即使存在于 locals() 中也没有定义 python 函数