因此,我有一個(gè)很大的凌亂組件,我將嘗試縮小它的體積,但是請(qǐng)保留其中大部分,因?yàn)槲也淮_定此時(shí)可能是什么原因。問(wèn)題是游戲可以按預(yù)期運(yùn)行。是時(shí)候渲染模態(tài)了,它出現(xiàn)在頁(yè)面的左下角,沒(méi)有樣式浮在左邊。但是,該功能可以正常工作,按鈕可以正常工作,并且可以顯示原始內(nèi)容。import { Modal } from 'antd';//rest of importsconst initialState = { visible: false, streak: 0, score: 0, turn: 0, previousPicks: [], result: { result: "", player: "", computer: "" }};class Game extends React.Component { constructor(props) { super(props); this.turnLimit = 10; this.state = initialState; } componentWillUnmount() { this.setState(initialState) } updateScore = () => { //handles score } updatePreviousPicks = () => { //update game data } onClickHandler = async (choice) => { //fetching data from backend self.showModal(); } getAIResult = () => { // } showModal = () => { if (this.state.turn === 10) { this.setState({ visible: true, }); } } handleOk = () => { this.setState(initialState) } handleCancel = () => { this.setState(initialState) } render() { return ( <div> <div> <Modal title="Basic Modal" centered={true} visible={this.state.visible} onOk={this.handleOk} onCancel={this.handleCancel}></Modal> </div> <div className="container"> <div id="rockDiv" className={`choice`} onClick={() => this.onClickHandler("rock")}> <Choices choice="rock"></Choices> </div> <div id="paperDiv" className={`choice`} onClick={() => this.onClickHandler("paper")}> <Choices choice="paper"></Choices> </div> <div id="scissorsDiv" className={`choice`} onClick={() => this.onClickHandler("scissors")}> <Choices choice="scissors"></Choices> </div> </div> ) }}export default Game我試過(guò)從組件中刪除所有CSS,但是模態(tài)不顯示為默認(rèn)的antd設(shè)計(jì)嗎?
react.js antd模態(tài)錯(cuò)誤行為
慕運(yùn)維8079593
2021-03-29 15:11:17