摘要: import React, { Component } from 'react'; import axios from 'axios'; class Axios extends Component { constructor(props) { super(props); this.state = { 阅读全文
posted @ 2020-08-01 18:23 maxweber 阅读(311) 评论(0) 推荐(0) 编辑
摘要: /* https://reactjs.org/docs/react-component.html React生命周期函数: 组件加载之前,组件加载完成,以及组件更新数据,组件销毁。 触发的一系列的方法 ,这就是组件的生命周期函数 组件加载的时候触发的函数: constructor 、componen 阅读全文
posted @ 2020-08-01 18:22 maxweber 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 1.父组件Home.js /* react获取服务器APi接口的数据: react中没有提供专门的请求数据的模块。但是我们可以使用任何第三方请求数据模块实现请求数据 1、axios https://github.com/axios/axios axios的作者觉得jsonp不太友好,推荐用CORS方 阅读全文
posted @ 2020-08-01 18:17 maxweber 阅读(307) 评论(0) 推荐(0) 编辑
摘要: 1.父组件 Home.js /* React中的组件: 解决html 标签构建应用的不足。 使用组件的好处:把公共的功能单独抽离成一个文件作为一个组件,哪里里使用哪里引入。 父子组件:组件的相互调用中,我们把调用者称为父组件,被调用者称为子组件 父子组件传值(react 父子组件通信): 父组件给子 阅读全文
posted @ 2020-08-01 18:13 maxweber 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 1.Header.jsimport React, { Component } from 'react'; class Header extends Component{ constructor(props){ super(props); //国定写法 this.state={ msg:'这是一个头部 阅读全文
posted @ 2020-08-01 18:09 maxweber 阅读(321) 评论(0) 推荐(0) 编辑
摘要: storage.js var storage={ set(key,value){ localStorage.setItem(key,JSON.stringify(value)); }, get(key){ return JSON.parse(localStorage.getItem(key)); } 阅读全文
posted @ 2020-08-01 17:59 maxweber 阅读(553) 评论(0) 推荐(0) 编辑
摘要: import React,{Component} from 'react'; import '../assets/css/index.css'; class Todolist extends Component { constructor(props) { super(props); this.st 阅读全文
posted @ 2020-08-01 17:56 maxweber 阅读(92) 评论(0) 推荐(0) 编辑
摘要: import React, { Component } from 'react'; class ReactForm extends Component { constructor(props) { super(props); this.state = { msg:"react表单", name:'' 阅读全文
posted @ 2020-08-01 17:52 maxweber 阅读(137) 评论(0) 推荐(0) 编辑
摘要: import React, { Component } from 'react'; /* 约束性和非约束性组件: 非约束性组:<input type="text" defaultValue="a" /> 这个 defaultValue 其实就是原生DOM中的 value 属性。 这样写出的来的组件, 阅读全文
posted @ 2020-08-01 17:51 maxweber 阅读(177) 评论(0) 推荐(0) 编辑
摘要: import React,{Component} from 'react'; class Todolist extends Component { constructor(props) { super(props); this.state = { username:"111" }; } inputC 阅读全文
posted @ 2020-08-01 17:48 maxweber 阅读(181) 评论(0) 推荐(0) 编辑
摘要: /* 事件对象 、键盘事件、 表单事件 、ref获取dom节点、React实现类似vue双休数据绑定 事件对象:在触发DOM上的某个事件时,会产生一个事件对象event。这个对象中包含着所有与事件有关的信息 */ import React from 'react'; import '../asset 阅读全文
posted @ 2020-08-01 17:47 maxweber 阅读(425) 评论(0) 推荐(0) 编辑
摘要: import React from 'react'; class List extends React.Component { constructor(props) { super(props); this.state = { username:'' }; } inputChange=()=>{ / 阅读全文
posted @ 2020-08-01 17:45 maxweber 阅读(134) 评论(0) 推荐(0) 编辑
摘要: import React from 'react'; import '../assets/css/index.css'; class Home extends React.Component{ // 子类必须在constructor方法中调用super方法,否则新建实例时会报错。这是因为子类没有自己 阅读全文
posted @ 2020-08-01 17:43 maxweber 阅读(112) 评论(0) 推荐(0) 编辑
摘要: import React from 'react'; import '../assets/css/index.css'; import logo from '../assets/images/1.jpg'; class News extends React.Component{ constructo 阅读全文
posted @ 2020-08-01 17:41 maxweber 阅读(305) 评论(0) 推荐(0) 编辑
摘要: import React from 'react'; import '../assets/css/index.css'; /* react绑定属性注意: class要换成className for要换成 htmlFor style: <div style={{"color":'red'}}>我是一个 阅读全文
posted @ 2020-08-01 17:39 maxweber 阅读(252) 评论(0) 推荐(0) 编辑
摘要: import React, { Component } from 'react'; class Home extends Component{ constructor(){ super(); //react定义数据 this.state={ name:"dyt", age:'30', userinf 阅读全文
posted @ 2020-08-01 17:36 maxweber 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 1.网络数据请求 cnpm install axios --save cnpm install fetch-jsonp --save 2.路由 cnpm install react-router-dom --save reudx cnpm install --save redux cnpm inst 阅读全文
posted @ 2020-08-01 17:27 maxweber 阅读(109) 评论(0) 推荐(0) 编辑