我正在使用 Ant-d Upload 通过本地系统上传文件,然后单击文件预览图像上的删除图标,图像文件将被删除。我想添加一个弹出确认,所以我尝试在 onRemovefunction 中添加确认作为承诺但它不起作用。它在浏览器中显示警报。
onGalleryFileRemove = (file)=>{
return new Promise((resolve, reject) => {
confirm({
title: 'are you sure to remove this file?',
onOk: () => {
resolve(true)
},
})
const index = this.state.galleryFile.indexOf(file);
const deletedGalleryFiles = this.state.deletedGalleryFiles;
deletedGalleryFiles.push(this.state.galleryFile[index].uid);
const newFileList = this.state.galleryFile.slice();
newFileList.splice(index, 1);
this.setState({
galleryFile:newFileList,
deletedGalleryFiles,
previewVisible:false
})
false
})
}
<Upload
listType="picture-card"
beforeUpload={this.beforeFileUpload}
fileList={this.state.galleryFile}
onPreview={this.handlePreview}
onChange={this.handleGalleryFileChange}
onRemove={this.onGalleryFileRemove}
>
{this.state.galleryFile.length >= 6 ? null : uploadGalleryButton}
</Upload>
<Modal visible={this.state.previewVisible} footer={null} onCancel={this.handleCancel}>
<img alt="previewImage" style={{ width: '100%' }} …Run Code Online (Sandbox Code Playgroud) 我需要添加到我的标志图片的链接。我的意思是当我点击我的标志图片时,它应该重定向到仪表板页面。我尝试使用锚标记来做到这一点,但它无法正常工作
<Header className='header' style={{ position: 'fixed', width: '100%' }}>
<div className='header-logo' style={{ width: collapsed ? 80 : 200, height: 0 }}>
{collapsed &&
<a href="/dashboard">
<img src={minLogo} alt='Logo' />
</a>
}
{ !collapsed &&
<span> </span>
}
</div>
<Icon
className="trigger"
type={collapsed ? 'menu-unfold' : 'menu-fold'}
onClick={this.toggleSideBar}
/>
<div style={{ display: 'inline-block', float: 'right' }}>
<Dropdown overlay={menu} placement="bottomRight">
<Avatar icon='user' />
</Dropdown>
</div>
</Header>
Run Code Online (Sandbox Code Playgroud)