首页 > 其他 > 详细

react笔记

时间:2016-06-16 19:54:30      阅读:109      评论:0      收藏:0      [点我收藏+]

注意事项:

1 Note that native HTML element names start with a lowercase letter, while custom React class names begin with an uppercase letter.

1 请注意原生HTML元素的名字以小写字母开头,而自定义的React类名字以大写字母开头;
特别注意:不管是原生HTML还是自定义React类其最高层元素(本例中comment-box类)不能出现兄弟及元素,且文本内容不得出现:<,即使输入& l t也无法显示小于号。这点真让人不爽!;
 
例如:React自定义类
var CommentBox=React.createClass({
  render:function(){
return (
 
hello world i am a comment box!
 
);
}
 });
ReactDOM.render(,$(‘#content‘)[0]);
 
原生HTML
var commentBox=
 
  hello world i am a comment box!
;
ReactDOM.render(commentBox,$(‘#content‘)[0]);

疑问:

Notice how we‘re mixing HTML tags and components we‘ve built. HTML components are regular React components, just like the ones you define, with one difference. The JSX compiler will automatically rewrite HTML tags to React.createElement(tagName)expressions and leave everything else alone. This is to prevent the pollution of the global namespace.(哪来的全局变量?)

react笔记

原文:http://www.cnblogs.com/a198/p/5591874.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!