Typescript React:我必须为超类构造函数指定参数吗?那会是什么争论呢?

问题描述 投票:0回答:1

可悲的是我不明白super()想要什么

export default class ScriptEditor extends React.Component<IScriptEditorProps, any> 
{
    constructor() 
{
        super();

        this._showDialog = this._showDialog.bind(this);
        this._closeDialog = this._closeDialog.bind(this);
        this._cancelDialog = this._cancelDialog.bind(this);
        this._onScriptEditorTextChanged = 
        this._onScriptEditorTextChanged.bind(this);

        const uiFabricCSS: string = `
.pzl-bgColor-themeDark, .pzl-bgColor-themeDark--hover:hover {
  background-color: "[theme:themeDark, default:#005a9e]";
}
`;
        loadStyles(uiFabricCSS);
        this.state = {
            showDialog: false
        };
}
reactjs typescript sharepoint-2010 web-parts super
1个回答
1
投票

您需要将props传递给像这样的react类构造函数:

© www.soinside.com 2019 - 2024. All rights reserved.