Reactjs 如何使用react中的onclick按钮将不同的js文件输出调用到另一个js文件
给定的是我创建为js文件的文件…..单击我注释的同一文件中的按钮 output.js中的button标签工作正常,如果我在不同的页面中更改按钮,那就是混乱 output.jsReactjs 如何使用react中的onclick按钮将不同的js文件输出调用到另一个js文件,reactjs,react-bootstrap,Reactjs,React Bootstrap,给定的是我创建为js文件的文件…..单击我注释的同一文件中的按钮 output.js中的button标签工作正常,如果我在不同的页面中更改按钮,那就是混乱 output.js import React, {Component} from 'react' import { Modal, Button } from 'react-bootstrap' class Threed extends Component { constructor(){ super()
import React, {Component} from 'react'
import { Modal, Button } from 'react-bootstrap'
class Threed extends Component {
constructor(){
super()
this.state ={show:false}
}
threedModal(){
this.setState({show:!this.state.show})
}
render() {
return (
<div>
{/*<Button onClick= {() => {this.threedModal()}}>
rajesh
</Button>*/}
<Modal show={this.state.show} onHide={() => this.handleModal()}>
<Modal.Header closeButton>MY popup</Modal.Header>
<Modal.Body>Rajesh modal done</Modal.Body>
<Modal.Footer><Button onClick= {() => {this.handleModal()}}> close </Button></Modal.Footer>
</Modal>
</div>
)
}
}
export default Threed
import React,{Component}来自“React”
从“react bootstrap”导入{Modal,Button}
类3D扩展组件{
构造函数(){
超级()
this.state={show:false}
}
三模态(){
this.setState({show:!this.state.show})
}
render(){
返回(
{/*{this.threedModal()}}>
拉杰什
*/}
this.handleModel()}>
我的弹出窗口
拉杰什·莫代尔
{this.handleModel()}}>关闭
)
}
}
导出默认的三维
home.js
import React, {Component} from 'react'
import { Modal, Button } from 'react-bootstrap'
import threed from './output.js'
class Threed extends Component {
constructor(){
super()
this.state ={show:false}
}
threedModal(){
this.setState({show:!this.state.show})
}
render() {
return (
<div>
<Button onClick= {() => {this.threedModal()}}>
rajesh
</Button>
</div>
)
}
}
export default Threed
import React,{Component}来自“React”
从“react bootstrap”导入{Modal,Button}
从“/output.js”导入三维
类3D扩展组件{
构造函数(){
超级()
this.state={show:false}
}
三模态(){
this.setState({show:!this.state.show})
}
render(){
返回(
{this.threedModal()}}>
拉杰什
)
}
}
导出默认的三维
我想在单击home.js按钮时显示,并显示模式弹出窗口。。。。。。
这里我的困惑是如何通过点击Home.js的按钮来获得该功能。请将值转发给modal Home.js
import Threed from./output.js'
类Home扩展组件{
...
Threed.js
this.handleModel()}>
您可以有条件地返回模式。仅当show
为真时返回模式,并始终返回按钮。