随笔分类 - ReactJS
摘要:React基础 1 组件通讯 1.1 props 子组件 import React from "react"; import PropTypes from "prop-types"; import { Button } from "antd"; export default class Eightt
阅读全文
摘要:const { getFieldDecorator, getFieldValue, setFieldsValue, resetFields, validateFields, getFieldError } = this.props.form; getFieldDecorator: 用于和表单进行双向
阅读全文
摘要:Flux 要点 功能组成: View: 视图层 Action(动作):视图层发出的消息(比如mouseClick) Dispatcher(派发器):用来接收Actions、执行回调函数 Store(数据层):用来存放应用的状态,一旦发生变动,就提醒Views要更新页面 执行流程: 用户访问 View
阅读全文
摘要:一、安装 dva-cli cnpm install dva-cli -g 二、创建应用 dva new dva-project 三、启动应用 cd dva-project npm start 四、安装并使用antd cnpm install antd babel-plugin-import --sa
阅读全文
摘要:'use strict' import 'semantic-ui/semantic.min.css!'; import React, { Component } from 'react'; import ReactDOM from 'react-dom'; // import { Router, R
阅读全文
摘要:打开CommentBox.js 修改handleCommentSubmit方法 handleCommentSubmit(comment){ // console.log(comment); let comments = this.state.data, newComments = comments.
阅读全文
摘要:儿子将获取到的数据提交给父亲 打开CommentBox.js 我们在CommentForm标签上添加onCommentSubmit={this.handleCommentSubmit} 创建handleCommentSubmit方法 handleCommentSubmit(comment){ con
阅读全文
摘要:在input和textarea标签上使用ref属性 <input type="text" placeholder="姓名" ref="author"/> <textarea placeholder="评论" ref="text"></textarea> 在onSubmit={this.handleS
阅读全文
摘要:事件处理函数的使用 鼠标事件: onClick onContextMenu onDoubleClick onMouseDown onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onDrop onDrag o
阅读全文
摘要:修改main.js CommentBox标签 <CommentBox url="app/comments.json"/>,document.getElementById('app') 在 app 文件夹下 新建 comments,json 文件 [ {"author": "journey" , "d
阅读全文
摘要:打开main.js 添加一些模拟数据 var comments = [ {"author": "journey" , "date" : "3分钟前" , "text" : "今天天气有点冷!"}, {"author": "jim" , "date" : "5分钟前" , "text" : "今天早上
阅读全文
摘要:在comment文件夹下新建Comment.js Comment.js 'use strict' import React from 'react'; class Comment extends React.Component{ render(){ return ( <div className="
阅读全文
摘要:在app下的comment文件夹下面分别新建CommentList.js 和 CommentForm.js CommentList.js 'use strict' import React from 'react'; class CommentList extends React.Component
阅读全文
摘要:在app文件夹下新建一个comment文件夹,并创建CommentBox.js CommentBox.js 'use strict'; import React from 'react'; class CommentBox extends React.Component{ render() { re
阅读全文
摘要:使用命令 jspm install react 进行安装 使用命令 jspm install react-dom 安装 react-dom 使用命令 jspm install semantic-ui 进行 semantic-ui样式的安装(不是必须) 使用 jspm install css 进行插件
阅读全文