我需要將影像 url 傳遞給 react js 中的模態。就像,單擊“imgae 附件”中的專案時,它會顯示帶有所選專案影像的模式。但它不能通過傳遞 img={item.document} 來顯示我的影像資料,下面是我的代碼:
I've updated the state's structure to group the modal props.
this.state = {
deps: [],
modal: {
show: false,
img: ""
}
};
addModalClose = () => this.setState({ modal: { show: false, img: "" } });
<Button
variant="primary"
onClick={() =>
this.setState({
modal: {
show: true,
img: item.document,
},
})
}
>
image attachment
</Button>;
<AddDepositModal
show={this.state.modal.show}
onHide={this.addModalClose}
img={this.state.modal.img}
/>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/410832.html
標籤:
