classModalextendsReact.Component {constructor(props){super(props)this.modalRef = React.createRef()}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>)}}classAppextendsReact.Component {state ={toOpen:false,}changeStatus=(toOpen)=>{this.setState({toOpen})}render(){return(<><Modal toOpen={this.state.toOpen}/><button onClick={()=>this.changeStatus(true)}>打开</button><button onClick={()=>this.changeStatus(false)}>关闭</button></>)}}
打开pubspec.yaml找到dependencies在最下面添加 dio: ^1.0.9ctrl s 之后,会自动下载依赖 使用:
// get请求
import package:dio/dio.dart;
Dio dio new Dio();
var response await dio.get("/test", data:{"id":12, "name":"marron&qu…
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…