<Upload
     className="w-full [&_.ant-upload-select]:!w-full"
      fileList={fileList}
      customRequest={customRequest}
      maxCount={1}
      accept=".docx,.doc,.pptx,.ppt"
      onRemove={() => {
        setFileList([])
        onChange?.('')
      }}
      onChange={(info) => {
        setFileList(info.fileList)
        if (info.file.status === 'error') {
          message.error(`${info.file.name} 上传失败`)
        }
      }}
    >
      {fileList.length < 1 && (
        <div className="flex cursor-pointer flex-col items-center rounded-xl border border-dashed border-gray-300 p-6">
          <PlusOutlined className="text-2xl text-gray-400" />
          <div className="mt-2 text-sm text-gray-400">点击或拖拽文件上传</div>
        </div>
      )}
</Upload>

[&_.ant-upload-select]:!w-full这一句是什么意思?
这是 Tailwind CSS 的 任意选择器(Arbitrary Selector) 语法,让我拆解一下:
[ ]    任意选择器定界符,里面写标准 CSS 选择器
&    引用当前元素自身(类似 Sass/Less 中的 &)
_.ant-upload-select    (空格)+ .ant-upload-select — 选中当前元素内部的所有 .ant-upload-select 子元素(后代选择器)
:    Tailwind 的变体分隔符
!    Tailwind 的 !important 前缀
w-full    Tailwind 的 width: 100%

Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐