如何更改“文件”的文本。 <输入> Antd
我相信标题是不言自明的。我已经检查了文档和其他一些线程,但是我根本无法设法更改标签的两个文本:也不是“选择文件”,也不是“不选择文件”。下面是我到目前为止尝试过的。我该如何更改这些文本?
{/* <label htmlFor="test" id="files">Test with classic label</label> */}
<Input
// addonAfter="test1"
// addonBefore="test2"
type="file"
onChange={handleFileSelected}
text="test"
/>
I believe the title is self-explanatory. I have checked the docs and some other threads, but I simply cannot manage to change both texts of the label: nor "Choose file", neither "No file chosen". Below is what I have tried so far. How could I change those texts?
{/* <label htmlFor="test" id="files">Test with classic label</label> */}
<Input
// addonAfter="test1"
// addonBefore="test2"
type="file"
onChange={handleFileSelected}
text="test"
/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
输入的文件元素的文本由浏览器控制,因此您无法直接更改该元素。您可以做的是创建一个可自定义的按钮,该按钮使用参考来控制输入的单击:
The text of the input's file element is controlled by the browser so you can not directly change that. What you can do is instead creating a customizable button that uses a ref to control the click on the input:
蚂蚁设计还具有 upload组件用于文件上传的文件上传,可以轻松样式上载
Ant Design also has Upload component for file uploading which could be styled easily