这是本人初学React做的学习笔记;讲的不是很深,只算是简单的进行介绍。

这是一个小系列。都是在同一个模板中搭建的,但是代码是不能正常执行的。

>>第一个组件.js
'use strick'
/*===========================JavaScript的XML语法========================*/
var CommentBox = React.createClass({
render:function () {
return (
<div className="CommentBox">
Hello, world!I am a CommentBox.
</div>
);
}
}); ReactDOM.render(
<CommentBox />,
document.getElementById('content')
); /*=====================以上JS语句将被翻译为;==========================*/
var CommentBox = React.createClass({displayName: 'CommentBox',
render: function() {
return (
React.createElement('div', {className: "CommentBox"},
"Hello, world!I am a CommentBox."
)
);
}
}); ReactDOM.render(
React.createElement(commentBox, null),
document.getElementById('content')
);
/*=============================撰写组件===================================*/ var CommentList = React.cracteClass({
render: function() {
return (
<div className="commentList">
Hello, React`s World!I am a Commentlist.I am form Lao Zhao.
</div>
);
}
}); var CommentForm = React.createClass({
render: function() {
return (
<div className="commentForm">
Hello React`s World!I am a CommentForm.I am from Lao Zhao.
</div>
); }
}); /*==============================更新组件===================================*/ var CommentBox = React.createClass({
render: function() {
return (
<div className="commentBox">
<h1>Comments</h1>
<CommentList />
<CommentForm />
</div>
);
}
}); /*==============================使用道具=======================================*/ var Comment = React.createClass({
render: function() {
return (
<div>
<h2 className="commentAuthor">
{this.props.author}
</h2>
{this.props.children}
</div>
);
}
}); /*===============================组件属性===========================================*/ var CommentList = React.createClass({
render: function() {
return (
<div className="commentList">
<Comment author="Zhao Gaosheng">This is one comment.</Comment>
<Comment author="Gaosheng">This is *another*comment.</Comment>
</div>
);
}
});

    这里只是简单让大家感受一下JSX的语法氛围。

初学React:JSX语法的更多相关文章

  1. React JSX语法说明

    原文:http://my.oschina.net/leogao0816/blog/379487 什么是JSX? 在用React写组件的时候,通常会用到JSX语法,粗看上去,像是在Javascript代 ...

  2. 2. React JSX语法及特点介绍

    什么是JSX         JSX 是一种类 XML 语言,全称是 JavaScript XML .React 可以不使用 JSX来编写组件,但是使用JSX可以让代码可读性更高.语义更清晰.对 Re ...

  3. React(JSX语法)-----JSX基本语法

    JSX------HTML tags vs React Components: 1.To render a html tag,just use lower-case tag names in JSX; ...

  4. 学习 React(jsx语法) + es2015 + babel + webpack

    视频学习地址: http://www.jtthink.com/course/play/575 官方地址 https://facebook.github.io/react/ 神坑: 1.每次this.s ...

  5. React(JSX语法)----动态UI

    1.React honws how to bubble and capture events according to the spec,and events passed to your event ...

  6. React(JSX语法)----JSX拼写

    注意:For DOM differences,such as the inline style attribute,check here. // bad: it displays "FIrs ...

  7. React(JSX语法)-----JSX属性

    1. if you know all the propertities that you want to place on a component ahead of time,it is easy t ...

  8. 22-React JSX语法

    React JSX语法 JSX只是一个语法糖,每一个XML标签都会被JSX转换工具转换成纯Javascript代码,当然你想直接使用纯Javascript代码写也是可以的,只是利用JSX,组件的结构和 ...

  9. Webstorm 不识别es6 import React from ‘react’——webstorm不支持jsx语法怎么办

    2016-10-31更新 webstorm不支持es6语法怎么办? webstorm不支持jsx语法怎么办? 参考:webstorm不支持jsx语法怎么办 I spent ages trying to ...

随机推荐

  1. beleline hive spark-shell帮助

    -- beeline帮助 : jdbc:hive2://100.69.216.40:10001> !help !addlocaldriverjar Add driver jar file in ...

  2. centos7-网络与防火墙常用命令

    1.网络配置 vi /etc/sysconfig/network-scripts/ifcfg-ens33 BOOTPROTO="static" IPADDR=192.168.163 ...

  3. 2 Sum

    Problem Given an array of integers, find two numbers such that they add up to aspecific target numbe ...

  4. T-SQL 聚合函数Count与NULL

    大家都知道聚合函数是做统计用的,而count函数是统计行数的,也就是满足一定条件记录的行数. 下面我们来看下这个count与NULL的微妙关系. CREATE TABLE dbo.Student ( ...

  5. vue-cli中webpack配置解析

    版本号 vue-cli 2.8.1 (终端通过vue -V 可查看) vue 2.2.2 webpack 2.2.1 目录结构 ├── README.md ├── build │ ├── build. ...

  6. Vue.js-----轻量高效的MVVM框架(八、使用组件)

    什么是组件? 组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.在较高层面上,组件是自定义元素,Vue.js 的编译器为它添加特殊功能.在有 ...

  7. Django自定义过滤器

    1.首先在在settings中的INSTALLED_APPS配置当前app,不然django无法找到自定义的simple_tag. 2.在app中创建templatetags模块(模块名只能是temp ...

  8. 使用require.js

    requirejs使用入门 什么是requirejs? RequireJS的目标是鼓励代码的模块化,它使用了不同于传统<script>标签的脚本加载步骤.可以用它来加速.优化代码,但其主要 ...

  9. 配置python环境使用tushare股票数据

    最近在做一个项目,主要是基于股票市场来验证一些model,看看能否做量化交易.那么如何获取数据呢?因为客户这边前期是不想花钱买数据的,只能自己想办法了,从sina和yahoo财经频道爬到一些数据,但是 ...

  10. spring的IOC和AOP详细讲解

    1.解释spring的ioc? 几种注入依赖的方式?spring的优点? IOC你就认为他是一个生产和管理bean的容器就行了,原来需要在调用类中new的东西,现在都是有这个IOC容器进行产生,同时, ...