问题
I'm trying to write an embedded powerbi interface for a website using ASP.NET and C#. Currently, I'm stuck on an error.
I am using the powerbi-javascript own github wiki in order to get a good idea on how to make it.
With some work I managed to get a bit of work around some problems and errors to get to it now.
However, as it stands now, I am not capable of solving this error.
The full message of the error is:
Severity Code Description Project File Line Suppression State Error TS2345 (TS) Argument of type '{ type: string; id: string; embedUrl: string; tokenType: any; accessToken: string; settings: { filterPaneEnabled: boolean; navContentPaneEnabled: boolean; }; }' is not assignable to parameter of type 'IEmbedConfigurationBase'. Types of property 'settings' are incompatible. Type '{ filterPaneEnabled: boolean; navContentPaneEnabled: boolean; }' has no properties in common with type 'ISettings'. TenantPortal C:\Users\ext-patrik.ek\source\repos\TenantPortal\TenantPortal\TenantPortal\wwwroot\js\powerbi.ts 20 Active
The TS code looks like this:
import * as pbi from 'powerbi-client';
let powerbi = new pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory);
var models = window['powerbi-client'].models;
var config = {
type: 'report',
id: 'ID',
embedUrl: 'https://app.powerbi.com/',
tokenType: models.TokenType.Embed,
accessToken: 'ACCESSTOKEN',
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
}
};
var $reportContainer = $('#reportContainer');
let report = powerbi.embed($reportContainer.get(0), config); // The error message is under config here
Anyone know why this is?
Before you all ask, the reason why accessToken and ID isn't filled in here is because of this is apart of a project and I can not show the work on it.
Thank you for the help.
回答1:
I think this error is due to type of config object and his properties.
You can try below format code:
const config = <IEmbedConfigurationBase> <any>{
type: 'report',
uniqueId: 'your-report-id ',
id: 'your-report-id ',
tokenType: 'Embed Token',
settings: {
navContentPaneEnabled: false,
filterPaneEnabled: false
},
embedUrl: 'your-embed url',
accessToken: 'your-access-token'
};
For more detail and refernce link - Interface IEmbedConfigurationBase
来源:https://stackoverflow.com/questions/60003890/ts-argument-of-type-is-not-assignable-to-parameter-of-type-iembedconf