react篇章-React 元件-複合元件

ZZZZW發表於2019-02-21
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>菜鳥教程 React 例項</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="example"></div>
<script type="text/babel">
function Name(props) {
	return <h1>網站名稱:{props.name}</h1>;
}
function Url(props) {
	return <h1>網站地址:{props.url}</h1>;
}
function Nickname(props) {
	return <h1>網站小名:{props.nickname}</h1>;
}

function NameBlog(props) {
	return <h1>部落格名稱:{props.name}</h1>;
}
function UrlBlog(props) {
	return <h2>部落格地址:{props.url}</h2>;
}
function NicknameBlog(props) {
	return <h3>部落格小名:{props.nickname}</h3>;
}
function App() {
	return (
	<div>
		<Name name="菜鳥教程" />
		<Url url="http://www.runoob.com" />
		<Nickname nickname="Runoob" />
	</div>
	);
}
function AppBlog() {
	return (
	<div>
		<NameBlog name="zzzzw的部落格" />
		<UrlBlog url="https://www.cnblogs.com/zzzzw" />
		<NicknameBlog nickname="zzzzw" />
	</div>
	);
}

ReactDOM.render(
	 <AppBlog />,
	document.getElementById('example')
);
</script>

</body>
</html>

  

 

相關文章