- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 React/Spring 初学者,我不知道如何使用 Primereact 制作文件上传。
他们的文档说明如下( https://www.primefaces.org/primereact/#/fileupload ):
FileUpload requires a url property as the upload target and a name to identify the files at backend.
<FileUpload name="demo" url="./upload"></FileUpload>
最佳答案
你可以这样做:
<FileUpload name="invoice"
accept="image/*"
customUpload={true}
uploadHandler={invoiceUploadHandler}
mode="basic"
auto={true}
chooseLabel="Upload invoice"/>
const invoiceUploadHandler = ({files}) => {
const [file] = files;
const fileReader = new FileReader();
fileReader.onload = (e) => {
uploadInvoice(e.target.result);
};
fileReader.readAsDataURL(file);
};
像这样发送您的请求
const uploadInvoice = async (invoiceFile) => {
let formData = new FormData();
formData.append('invoiceFile', invoiceFile);
const response = await fetch(`orders/${orderId}/uploadInvoiceFile`,
{
method: 'POST',
body: formData
},
);
};
重要提示:不要设置任何
Content-Type
头!这将自动完成。
关于reactjs - 如何使用 PrimeReact FileUpload 组件上传文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60389073/
我似乎无法使用 styled-component 来设置 PrimeReact 组件的样式。 鉴于下面的代码呈现一个 InputText,我的意图是改变它的宽度。但它不起作用。 import styl
我是 Node、JavaScript 和 React 的新手。我必须在下拉列表中显示数据列表,然后将选定的数据保存在数据库中。问题是如何显示要选择的数据列表 他们以这种方式获取数据
我希望能够在 primereact 的主题之间切换,而不是导入一个主题,然后它会影响我的整个应用程序,而且我没有在暗模式或亮模式之间切换的选项。 最佳答案 在网站上观察他们是怎么做的www.prime
我正在使用 prime react 数据表 显示数据表,当鼠标悬停在单元格上时,我想显示工具提示或标题,如下图所示。 我检查了 Column 组件,但没有找到任何相关关键字来显示单元格上的工具提示或标
我想使用 Primereact 框架开发一个 React Js 应用程序。现在我遇到了一些导入无法找到的问题。 Import import {Button} from 'primereact/Butt
我想知道是否可以在 PrimeReact 中使用 react-icons 包中的图标,因为不幸的是 primeIcons 包不包含我的项目所需的所有图标。 我还没有找到解决方案,因为 react-ic
我是 React/Spring 初学者,我不知道如何使用 Primereact 制作文件上传。 他们的文档说明如下( https://www.primefaces.org/primereact/#/f
我正在尝试在我的项目中使用 PrimeReact 的编辑器组件 import React from 'react'; import Editor from './editor/Editor'; con
我试图将焦点集中在 primereact 的“Dropdown”组件上,但焦点并未集中在“Dropdown”组件上。 我已经使用了 https://www.primefaces.org/primere
我收到以下错误- Failed to compile ./node_modules/primereact/components/dropdown/DropdownPanel.js Module not
我启用了 CSS modules within webpack.config在我的 React 应用程序中,这样我就可以在本地将 CSS 文件范围限定到各个组件。我也在尝试使用 PrimeReact
我是一名优秀的程序员,十分优秀!