####react最基础的语法和不依赖环境的纯前端免编译代码

参照:http://www.ruanyifeng.com/blog/2015/03/react.html

注意事项:1.必须放倒服务器上,在文件系统上无法运行

login.html

<!doctype html>

<head>
<meta charset="utf-8"> <!--reset.css-->
<link rel="stylesheet" href="/frontend/css/reset.css" /> <!--jquery-->
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script> <!--react【核心库】【dom操作库】【jsx语法库】-->
<script src="https://cdn.bootcss.com/react/15.4.2/react.min.js"></script>
<script src="https://cdn.bootcss.com/react/15.4.2/react-dom.min.js"></script>
<script src="https://cdn.bootcss.com/babel-standalone/6.22.1/babel.min.js"></script> <!--bootStrap-->
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.2/css/bootstrap.min.css" >
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.2/css/bootstrap-theme.min.css" >
<script src="http://cdn.bootcss.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> <!--jquery.cookie-->
<script src="http://apps.bdimg.com/libs/jquery.cookie/1.4.1/jquery.cookie.js"></script> <link rel="stylesheet" href="login.css" type="text/css" />
<title>
页面
</title>
</head>
<body style="margin: auto">
<div id="root"></div> <script type="text/babel" src="login.js"></script> </body>
</html>

  

login.css

.login{
background-color: red;
} .header{
height: 30px;
background-color: gray;
} .userRole{
height:80px;
background-color: lightcyan;
}
.userId{ }
.userPassword{ } .submitButtonEnabled{
color:blue;
}
.submitButtonDisabled{
color: gray;
}

  

login.js

class Login extends React.Component{

    //props的类型和是否必须填写
// static propTypes = {
// }; constructor(props) {
super(props);
this.state = {
userId: '',
userPassword: '',
submitEnabled: false,
};
} componentWillMount() {
console.log("componentWillMount");
} componentDidMount() {
console.log("componentDidMount");
} componentWillUnmount() {
console.log("componentWillUnmount"); } //event
handleClickSubmit() {
if(this.state.userId.length < 1 || this.state.userPassword.length < 1){
return;
}
$.get("http://publicschool.sinaapp.com/test/test.php?name=jack", function(result) {
console.log(result);
});
}
handleChangeId () {
this.setState({
userId:this.refs._ref_userId.value,
submitEnabled:this.refs._ref_userId.value.length > 0 && this.refs._ref_userPassword.value.length > 0,
});
}
handleChangePassword () {
this.setState({
userPassword:this.refs._ref_userPassword.value,
submitEnabled:this.refs._ref_userId.value.length > 0 && this.refs._ref_userPassword.value.length > 0,
});
} //渲染方法
render () {
return(
<div className="login">
<div className="header">
{this.props.title}
</div> <div className="userRole">
{this.props.role}
</div> <input className="userId" type="text" ref="_ref_userId" placeholder="用户名" onChange={()=>this.handleChangeId()} />
<input className="userPassword" type="password" ref="_ref_userPassword" placeholder="密码" onChange={()=>this.handleChangePassword()} /> <button type="button" onClick={()=>this.handleClickSubmit()}
className={this.state.submitEnabled?"submitButtonEnabled":"submitButtonDisabled"}>登录</button>
</div>); }
} ReactDOM.render(
<Login title="title" role="ddd"/>,
document.getElementById('root')
);

  

  

react纯前端不依赖于打包工具的代码的更多相关文章

  1. 细说前端自动化打包工具--webpack

    背景 记得2004年的时候,互联网开发就是做网页,那时也没有前端和后端的区分,有时一个网站就是一些纯静态的html,通过链接组织在一起.用过Dreamweaver的都知道,做网页就像用word编辑文档 ...

  2. Jenkins 实现前端自动打包,自动部署代码及邮件提醒功能

    在之前的公司,我们前端使用webpack构建项目,项目构建完成后,我们会使用ftp或linux的一些命令工具上传我们的文件到服务器上,这种方式虽然是可以,但是最近面试的时候,人家会问我前端如何部署项目 ...

  3. 简单理解 Webpack,以及Web前端使用打包工具的原因

    Java 中的模块 传统的前端开发就是 JS.HTML.CSS 三件套.Web 没有像 Java 一样拥有优秀的模块机制,就是类与类之间可以分装在不同的包下,不同包下的类互相引用时通过import导入 ...

  4. 前端项目打包工具weexpack的安装

    最下面是本人安装时候的系统环境,本篇文章只限于参考,不一定非得是这样,原因你懂得. 打包的过程中出现的问题 1.执行到weexpack run android的时候,到了resolving class ...

  5. 模拟webpack 实现自己的打包工具

    本框架模拟webpack打包工具 详细代码个步骤请看git地址:https://github.com/jiangzhenfei/easy-webpack 创建package.json { " ...

  6. 一个基于React整套技术栈+Node.js的前端页面制作工具

    pagemaker是一个前端页面制作工具,方便产品,运营和视觉的同学迅速开发简单的前端页面,从而可以解放前端同学的工作量.此项目创意来自网易乐得内部项目nfop中的pagemaker项目.原来项目的前 ...

  7. Webpack:前端资源模块化管理和打包工具

    一.介绍: Webpack 是当下最热门的前端资源模块化管理和打包工具.它可以将许多松散的模块按照依赖和规则打包成符合生 产环境部署的前端资源.还可以将按需加载的模块进行代码分隔,等到实际需要的时候再 ...

  8. 前端框架VUE----webpack打包工具的使用

    在这里我仅仅的是对webpack做个讲解,webpack这个工具非常强大,解决了我们前端很繁琐的一些工具流程繁琐的事情.如果感兴趣的同学,还是看官网吧. 中文链接地址:https://www.webp ...

  9. 【案例分享】在 React 框架中使用 SpreadJS 纯前端表格控件

    [案例分享]在 React 框架中使用 SpreadJS 纯前端表格控件 本期葡萄城公开课,将由国电联合动力技术有限公司,资深前端开发工程师——李林慧女士,与大家在线分享“在 React 框架中使用 ...

随机推荐

  1. [前端_EasyUI]给easyui的datebox设置默认值,获取不到 的解决方法

    //给eayui datebox设置初始值 $("#ctime").datebox("setValue", function(){ var date = new ...

  2. PIC32MZ tutorial -- Watchdog Timer

    Watchdog is a very necessary module for embedded system. Someone said that embedded system operates ...

  3. 6. js时间比较

    var v0 = ABS_DATESTRING(O_PARAMETER.FDate,"yyyy/MM/dd")var v_beginTime = v0 + " " ...

  4. mongo 查找附近点

    db.runCommand({geoNear:"demo", near: { type: "Point" , coordinates: [118.134535, ...

  5. error C2259: 'CException' : cannot instantiate abstract class

    vc6.0编译通过,VS2008则报错 解决方法: 把CException改为CUserException

  6. ecshop的特点,持续加新

    一.目录文件结构 入口文件index.php,define('IN_ECS', true); 只有为true时才可以进入. 首先加入init.php,在这个文件里: @ini_set('memory_ ...

  7. 用jsch.jar实现SFTP上传下载删除

    java类: 需要引用的jar: jsch-0.1.53.jar 关于jsch有篇文章关于目录的问题写得非常好:http://www.zzzyk.com/show/9f02969327434a6c.h ...

  8. 使用JNDI或JDBC连接数据库

    一. JNDI 1. tomcat环境 找到X:\xxx\......\apache-tomcat-6.0.39\conf\server.xml,在<Host>节点中配置如下: <H ...

  9. 《机器学习实战》学习笔记——第14章 利用SVD简化数据

    一. SVD 1. 基本概念: (1)定义:提取信息的方法:奇异值分解Singular Value Decomposition(SVD) (2)优点:简化数据, 去除噪声,提高算法的结果 (3)缺点: ...

  10. win下搭建uvm环境

    UVM验证方法学,很好的验证工具,下面用ModelSim-uvm做一个Hello world. 1.安装modelsim se 10.1a 2.下载uvm_1.1d  uvm-1.1d.tar.gz  ...