React Props 就像 JavaScript 中的函数参数
和HTML 中的属性。
const myElement = <Car brand="Toyota" />;
class Car extends React.Component {
render(){
return <h2>I love {this.props.brand}!</h2>
}
};
完整程序码
import React from "react";
import ReactDOM from "react-dom";
class Car extends React.Component {
render(){
return <h2>I love {this.props.brand}!</h2>
}
};
const myElement = <Car brand="Toyota" />;
ReactDOM.render(myElement, document.getElementById('root'));
输出结果>>>
I love Toyota!
参考来源:
https://www.w3schools.com/react/react_props.asp
>>: 大共享时代系列_013_网页浏览器(web browser)
Key-value 版本兼容警告 如果key不加引号 $data=[ john1=>1.2, ...
先公布昨天小练习的答案: 小练习:宣告一个公开、可读不可写、名为abc的function,参数a为...
The Mediator design pattern defines an object that...
大型数字 ( 图形数字 ) 教学原文参考:大型数字 ( 图形数字 ) 如果要在 Scratch 3 ...
出牌 出牌跟之前的游戏准备按钮一样 帮一个元件加上 phx-clixk 再绑上对应的动作, 唯一的差...