绑定属性
原创
©著作权归作者所有:来自51CTO博客作者wg_iGBFcBFB的原创作品,请联系作者获取转载授权,否则将追究法律责任
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>
<div id="app"></div>
<script type="text/babel">
// 封装App 组件
class App extends React.Component{
constructor(){
super();
this.state = {
title:'标题',
// imagUrl:'https://himg.bdimg.com/sys/portrait/item/wise.1.7410f781.uIX3cBSrpKoNZuTngAm-Sg.jpg?time=8674'
imagUrl:"" ,
active: true
}
}
render(){
const {title,imagUrl,active} = this.state;
return (
<div>
<h2 title={title}>我是标题</h2>
<img src={imagUrl} alt="" />
<div className="box title">我是div元素</div>
<div className={"box title " + (active ? 'active' : '')}>我也是div元素</div>
<div style={{color:"red",fontSize:50}}>我是div元素,绑定style样式</div>
</div>
)
}
}
ReactDOM.render(<App/>,document.getElementById('app'));
</script>
</body>
</html>

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
【CSS】:背景属性
【CSS】:背景属性
插入图片 3d html CSS -
属性绑定vue属性绑定
-
android Sqlite索引查询大数据查询次数多了之后变得缓慢
一个完整的SQL SERVER数据库全文索引的示例。(以pubs数据库为例) 首先,介绍利用系统存储过程创建全文索引的具体步骤: 1) 启动数据库的全文处理功能 (sp_fulltext_database) 2)&
数据库 sql server database sqlserver table