onChange 在 reactstrap 自定义输入开关中不起作用
onChange is not working in reactstrap custom input switch
代码:
import { CustomInput } from 'reactstrap'
...
const changeMediaStatus = (e) => {
console.log(e)
}
...
<CustomInput
type="switch"
className="ml-auto mr-1"
onChange={(e) =>changeMediaStatus(e)}
/>
在上面的代码中,分配给“onChange”属性的函数不起作用。而且,带有 onChange 属性的 CustomInput 组件不工作。
如何在 reactstrap CustomInput 组件上为 onChange 事件分配一个函数?
为 CustomInput 提供 id
。
<CustomInput
type="switch"
id="id-1"
className="ml-auto mr-1"
onChange={(e) => changeMediaStatus(e)}
/>
https://stackblitz.com/edit/reactstrap-1ttkao?file=Example.js
代码:
import { CustomInput } from 'reactstrap'
...
const changeMediaStatus = (e) => {
console.log(e)
}
...
<CustomInput
type="switch"
className="ml-auto mr-1"
onChange={(e) =>changeMediaStatus(e)}
/>
在上面的代码中,分配给“onChange”属性的函数不起作用。而且,带有 onChange 属性的 CustomInput 组件不工作。
如何在 reactstrap CustomInput 组件上为 onChange 事件分配一个函数?
为 CustomInput 提供 id
。
<CustomInput
type="switch"
id="id-1"
className="ml-auto mr-1"
onChange={(e) => changeMediaStatus(e)}
/>
https://stackblitz.com/edit/reactstrap-1ttkao?file=Example.js