当前位置: 首页 > 知识库问答 >
问题:

React Typescript组件中缺少属性

谢烨烨
2023-03-14

反应组分

import {Input} from '@xxx/forms';
<Input  label="account Name" name="account"/>
import React, { Ref } from 'react';
import { InputProps as UITKInputProps } from '@xxx/input';
import { WithStyles, Density } from '@xxx/theme';
import { FormFieldProps as FormFieldPropsType } from '../FormField';
import { NecessityStyle } from '../types';
import styles from './styles';
export declare type InputProps = WithStyles<typeof styles> & UITKInputProps & {
    name: string;
    label?: string;
    id?: string;
    disabled?: boolean;
    FormFieldProps?: Omit<FormFieldPropsType, 'children' | 'name' | 'label'>;
    required?: boolean;
    necessityStyle?: NecessityStyle;
    helperText?: string;
    ref?: Ref<any>;
    fullWidth?: boolean;
    density?: Density;
};
declare const StyledInput: React.ComponentType<Pick<React.PropsWithChildren<InputProps>, "required" | "disabled" | "error" | "hidden" | "dir" | "label" | "slot" | "style" | "title" | "color" | "ref" | "children" | "onBlur" | "onChange" | "onSubmit" | "name" | "onFocus" | "defaultValue" | "id" | "textAlign" | "translate" | "margin" | "className" | "innerRef" | "defaultChecked" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "type" | "fullWidth" | "autoFocus" | "value" | "inputProps" | "inputRef" | "readOnly" | "multiline" | "autoComplete" | "endAdornment" | "inputComponent" | "renderSuffix" | "rows" | "rowsMax" | "rowsMin" | "startAdornment" | "disableUnderline" | "density" | "necessityStyle" | "helperText" | "cursorPositionOnFocus" | "emptyReadOnlyMarker" | "highlightOnFocus" | "FormFieldProps"> & import("@material-ui/styles").StyledComponentProps<"disabled" | "input" | "root" | "readOnly" | "focused" | "multiline" | "inputMultiline" | "endAdornment" | "startAdornment" | "lowDensity" | "touchDensity" | "mediumDensity" | "highDensity" | "field">>;
export { StyledInput as Input };

如何在组件中声明输入组件?

共有1个答案

钮瀚
2023-03-14

虽然您没有为With StylesUITKinputProps提供完整的类型定义,但我猜它们内部有很多必需的道具。因此,您的inputprops类型将被扩展为一个庞大的列表,其中包括这两种类型中所需的道具,以及带有所需name字段的显式定义的道具。因此错误。

如果希望inputprops类型具有唯一必需的字段name,可以将其定义为:

export declare type InputProps 
  = Partial<WithStyles<typeof styles>>
  & Partial<UITKInputProps> 
  & {
        name: string;
        label?: string;
        id?: string;
        disabled?: boolean;
        FormFieldProps?: Omit<FormFieldPropsType, 'children' | 'name' | 'label'>;
        required?: boolean;
        necessityStyle?: NecessityStyle;
        helperText?: string;
        ref?: Ref<any>;
        fullWidth?: boolean;
        density?: Density;
    };
 类似资料:
  • 问题内容: C#具有用于声明和使用属性的语法。例如,可以声明一个简单的属性,如下所示: 也可以在属性中添加一些逻辑,如下所示: 无论是否具有逻辑,属性的使用方式与字段相同: 我对Java或C#都不陌生-我已经使用了很多东西,而且我总是想念Java中使用属性语法。我在这个问题中读到“在Java7中或将来几乎不可能添加属性支持”,但是坦率地说,我发现在讨论,论坛,博客,评论和JSR中需要挖掘太多的工作

  • 我将我的Fabric8 Spring Boot Camel pom.xml升级到使用Camel 2.16.0,但并非所有组件都在2.16.0中可用 我不得不将以下组件保留在2.15.3,因为我得到了2.16.0版本的“丢失项目”: 骆驼指标 骆驼jsonpath 骆驼Spring靴 这些在Camel 2.16.0中不可用吗? 我使用的是Fabric8版本2.2.46和Spring Boot版本1.

  • 运行flutter doctor时,即使我安装了cmdline tools,也会出现错误{cmdline tools component is missing},如下所示: 我还运行c:/sdk/tools/bin/sdkmanager--安装“cmdline tools;latest”,输出显示如下所示,

  • 在我的子组件中,我定义了道具接口,并将其包含在React中。组件。 然后需要将这些道具从父组件传递到子组件。到目前为止,一切都是合理的。。 但是,当我使用react router Typescript中的RouteComponents Props扩展Props接口时,也要求我传递“历史、位置、匹配”,我认为我不应该手动传递。。。 我不认为它与RouteComponentProps特别相关,因为在某

  • 我正在VSCode中使用OpenAPI 3编写一个API文档,扩展为OpenAPI(Swagger)Editor v4.9.1。直到今天它都运行良好-突然我的文档在所有模式声明中充满了“属性”错误。错误是:

  • 问题内容: 在从openni编译演示时,我偶然发现了此错误: 我在Mac上执行此操作。我最好的猜测是该文件不在我的java.library.path中 我现在的问题是:这个猜测正确吗,以及如何在netbeans中添加到java.library.path中。 提前Thx 问题答案: 将此添加到projects属性的VM选项中:-Djava.library.path = / Users / olivi