【问题标题】:react-dropzone error TS2322: Type 'string | { "image/*": string[]; }' is not assignable to type 'Accept'react-dropzone 错误 TS2322: Type \'string | { \"图片/*\": 字符串[]; }\' 不可分配给类型 \'Accept\'
【发布时间】:2023-01-01 02:45:18
【问题描述】:

“反应下降区”:“^ 14.2.2”

 const { getRootProps, getInputProps, isDragActive } = useDropzone({
    accept: {
      "image/*": [".jpeg", ".png", ".jpg"],
    },

错误:

MediaField.tsx:266:5 - error TS2322: Type 'string | { "image/*": string[]; }' is not assignable to type 'Accept'.
  Type 'string' is not assignable to type 'Accept'.

266     accept: {
        ~~~~~~

  node_modules/react-dropzone/typings/react-dropzone.d.ts:31:3
    31   accept?: Accept;
         ~~~~~~
    The expected type comes from property 'accept' which is declared here on type 'DropzoneOptions'

我想念什么?

【问题讨论】:

    标签: typescript image react-dropzone http-accept-header


    【解决方案1】:

    请改用此代码。

     accept:{
        'image/png': ['.png'],
        'image/jpg': ['.jpg'],
        'image/jpeg': ['.jpeg'],
        },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-09
      • 2019-02-05
      • 1970-01-01
      • 1970-01-01
      • 2018-10-11
      • 1970-01-01
      • 2019-03-19
      • 2021-04-15
      相关资源
      最近更新 更多