如何将布尔值传递给控件react.js
如何将布尔值传递给控件react.js
类应用程序扩展react.component {
constructor(props) {
**// Calling super class constructor**
super(props);
**// Creating state**
this.state ={
video.controls= false
}
}
render() {
return (
<div className= "container">
<video controls>
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4"></source>
<p>Your browser doesn't support HTML5 video.</p>
</video>
</div>
);
} }
导出默认应用程序;
How to pass Boolean value to the controls React.Js
class App extends React.Component {
constructor(props) {
**// Calling super class constructor**
super(props);
**// Creating state**
this.state ={
video.controls= false
}
}
render() {
return (
<div className= "container">
<video controls>
<source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4"></source>
<p>Your browser doesn't support HTML5 video.</p>
</video>
</div>
);
} }
export default App;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将状态值传递到
&lt; video&gt;
标签中。为此,您需要在代码中应用两个更改:第一个更改,作为一个建议,请勿直接在您的州内创建一个嵌套对象,如果您想添加一个嵌套对象,我绝对建议您使用格式:
视频:{控制:false}
当前video.controls = false
value的格式。因此,它将结束是这样的:然后,您可以将状态包装到对象键
{}
::You have to pass the state value into the
<video>
tag. To do it, you need to apply two changes in your code:The first one, and as a suggestion, is to not create a nested object directly in your state, if you want to add a nested object I would definitely recommend you to use the format of:
video: { controls: false }
insead of your currentvideo.controls = false
value. So it would end being something like this:And then you could use the state into the tag by wrapping it into object keys
{}
: