Reactjs 多反应钢筋混凝土滑块。。。不知道如何找出到底是哪一个在改变
我为我的产品提供了一个包含服务的可变列表,我为每项服务提供了一个rc滑块组件,以减少/增加用户对每项服务的需求量(如培训日、用户许可证等) 下面的代码为我的每个服务提供了一个滑块,但是。。。每个rc滑块仅返回滑块的数值,但我无法识别实际更改的滑块Reactjs 多反应钢筋混凝土滑块。。。不知道如何找出到底是哪一个在改变,reactjs,Reactjs,我为我的产品提供了一个包含服务的可变列表,我为每项服务提供了一个rc滑块组件,以减少/增加用户对每项服务的需求量(如培训日、用户许可证等) 下面的代码为我的每个服务提供了一个滑块,但是。。。每个rc滑块仅返回滑块的数值,但我无法识别实际更改的滑块 <ul className="included-services-amounts"> {productIncludedServices.map( function(productIncludedService, i) {
<ul className="included-services-amounts">
{productIncludedServices.map( function(productIncludedService, i) {
return (
<li key={i}>
<div>{productIncludedService.name}</div>
<Slider dots min={productIncludedService.range[0]} max={productIncludedService.range[1]} step={1} defaultValue={10} onChange={updateIncludedServicesFunc.bind(this)} />
</li>
)
})}
</ul>
或者用其他方法来找出哪个滑块组件实际发生了变化?是的,有几种方法可以做到这一点
class App extends React.Component {
method1(e) {
console.log(e.target.getAttribute("data-params"));
}
method2 = params => {
console.log(params);
};
method3(params) {
console.log(params);
}
render() {
return (
<div className="App">
<button
data-params="params from method 1"
onClick={this.method1.bind(this)}
>
method 1
</button>
<button
onClick={() => {
this.method2("params from method 2");
}}
>
method 2
</button>
<button onClick={this.method3.bind(this, "params from method 3")}>
method 3
</button>
</div>
);
}
}
类应用程序扩展了React.Component{
方法1(e){
log(e.target.getAttribute(“数据参数”);
}
方法2=参数=>{
控制台日志(params);
};
方法3(参数){
控制台日志(params);
}
render(){
返回(
方法1
{
方法2(“方法2的参数”);
}}
>
方法2
方法3
);
}
}
class App extends React.Component {
method1(e) {
console.log(e.target.getAttribute("data-params"));
}
method2 = params => {
console.log(params);
};
method3(params) {
console.log(params);
}
render() {
return (
<div className="App">
<button
data-params="params from method 1"
onClick={this.method1.bind(this)}
>
method 1
</button>
<button
onClick={() => {
this.method2("params from method 2");
}}
>
method 2
</button>
<button onClick={this.method3.bind(this, "params from method 3")}>
method 3
</button>
</div>
);
}
}