react纯前端不依赖于打包工具的代码
####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纯前端不依赖于打包工具的代码的更多相关文章
- 细说前端自动化打包工具--webpack
背景 记得2004年的时候,互联网开发就是做网页,那时也没有前端和后端的区分,有时一个网站就是一些纯静态的html,通过链接组织在一起.用过Dreamweaver的都知道,做网页就像用word编辑文档 ...
- Jenkins 实现前端自动打包,自动部署代码及邮件提醒功能
在之前的公司,我们前端使用webpack构建项目,项目构建完成后,我们会使用ftp或linux的一些命令工具上传我们的文件到服务器上,这种方式虽然是可以,但是最近面试的时候,人家会问我前端如何部署项目 ...
- 简单理解 Webpack,以及Web前端使用打包工具的原因
Java 中的模块 传统的前端开发就是 JS.HTML.CSS 三件套.Web 没有像 Java 一样拥有优秀的模块机制,就是类与类之间可以分装在不同的包下,不同包下的类互相引用时通过import导入 ...
- 前端项目打包工具weexpack的安装
最下面是本人安装时候的系统环境,本篇文章只限于参考,不一定非得是这样,原因你懂得. 打包的过程中出现的问题 1.执行到weexpack run android的时候,到了resolving class ...
- 模拟webpack 实现自己的打包工具
本框架模拟webpack打包工具 详细代码个步骤请看git地址:https://github.com/jiangzhenfei/easy-webpack 创建package.json { " ...
- 一个基于React整套技术栈+Node.js的前端页面制作工具
pagemaker是一个前端页面制作工具,方便产品,运营和视觉的同学迅速开发简单的前端页面,从而可以解放前端同学的工作量.此项目创意来自网易乐得内部项目nfop中的pagemaker项目.原来项目的前 ...
- Webpack:前端资源模块化管理和打包工具
一.介绍: Webpack 是当下最热门的前端资源模块化管理和打包工具.它可以将许多松散的模块按照依赖和规则打包成符合生 产环境部署的前端资源.还可以将按需加载的模块进行代码分隔,等到实际需要的时候再 ...
- 前端框架VUE----webpack打包工具的使用
在这里我仅仅的是对webpack做个讲解,webpack这个工具非常强大,解决了我们前端很繁琐的一些工具流程繁琐的事情.如果感兴趣的同学,还是看官网吧. 中文链接地址:https://www.webp ...
- 【案例分享】在 React 框架中使用 SpreadJS 纯前端表格控件
[案例分享]在 React 框架中使用 SpreadJS 纯前端表格控件 本期葡萄城公开课,将由国电联合动力技术有限公司,资深前端开发工程师——李林慧女士,与大家在线分享“在 React 框架中使用 ...
随机推荐
- 通知 Notification
1. NotificationManager ma=(NotificationManager) context.getSystemService(context.NOTIFICATION_SERVIC ...
- django中的静态文件管理
一个站点通常需要保存额外的文件,比如图片 css样式文件 js脚本文件 ,在django中,倾向于将这些文件称为 静态文件.django提供了django.contrib.staticfile ...
- mysql事件定时
DELIMITER $$ MONTH STARTS '2013-01-07 11:20:00' ON COMPLETION PRESERVE ENABLE DO BEGIN CALL ps(); EN ...
- 国内外著名B2C系统介绍兼比较ASP.NET和PHP
国内外著名B2C系统介绍兼比较ASP.NET和PHP 2010-06-08 11:44 来源: 我来投稿 我要评论 中介交易 SEO诊断淘宝客 站长团购 云主机 A5外包 国内外著名 ...
- 【Jquery mobile】动态加载ListView 转
[Jquery mobile]动态加载ListView 分类: Jquery Mobile2011-12-01 09:04 13984人阅读 评论(1) 收藏 举报 jquerylistviewmob ...
- 获取DataGridView中的的选中行
1. 获取DataGridView中的的选中行:http://blog.csdn.net/yiqijinbu/article/details/7734593 2.winform datagridvie ...
- 关于git新建本地分支与远程分支关联问题
背景 新建本地分支并推送到远端后,当前分支没有与远端分支关联,每次推送都需要填写一堆信息. 操作 git branch --set-upstream-to=origin/20160928 切换到本地分 ...
- ELK日志管理之——logstash部署
1.yum源配置 [root@localhost ~]# cat > /etc/yum.repos.d/logstash.repo <<EOF [logstash-1.5] name ...
- 通过字符串寻找与字符串一致的model的属性
// 取得选中权限集合 string[] arrAuthorityId = this.hidAuthorityIds.Value.TrimEnd(',').Split(','); BLBQ_Autho ...
- jQuery Mobile 过渡效果
jQuery Mobile 包含了允许您选择页面打开方式的 CSS 效果. jQuery Mobile 过渡效果 jQuery Mobile 拥有一系列关于如何从一页过渡到下一页的效果. 注释:如需实 ...