classModalextendsReact.Component {constructor(props){super(props)this.modalRef = React.createRef()console.log('刚创建时',this.modalRef)}componentDidMount(){console.log('componentDidMount',this.modalRef)}componentDidUpdate(){console.log('componentDidUpdate',this.modalRef)}render(){return(<divref={this.modalRef}style={{width:'300px',border:'1px solid #000',display:this.props.toOpen ?'block':'none'}}><h1>This is a Modal</h1><p>This is a super Modal</p></div>)}}
Mac hexo s 启动Hexo服务报错如下: Error: The module /usr/local/lib/node_modules/hexo-cli/node_modules/.0.8.0dtrace-provider/build/Release/DTraceProviderBindings.node
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. T…
JSX的props.children和props本身有部分一致的特性 props.children可以传递任何类型的子元素 // 调用子元素回调 num 次,来重复生成组件
function Repeat(props) {// 返回一组JSXlet items [];for (let i 0; i < props.num; i) {items.push(props.children(i));…
从实际出发理解. 首先看下面代码
// js
var dt new Date();
console.log(dt);下面想把时间格式化,写一个dateFormat函数
// js
function dateFormat(data){var dt new Date(data);var y dt.getFullYear();var m dt. getMonth() 1;var d dt.getDate();var hh dt.getHo…