博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
react纯前端不依赖于打包工具的代码
阅读量:4653 次
发布时间:2019-06-09

本文共 2341 字,大约阅读时间需要 7 分钟。

 

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

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

 

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

 

login.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(        
{this.props.title}
{this.props.role}
this.handleChangeId()} />
this.handleChangePassword()} />
); }}ReactDOM.render(
, document.getElementById('root'));

  

  

转载于:https://www.cnblogs.com/dongfangchun/p/6260916.html

你可能感兴趣的文章
php中的global关键字是啥意思
查看>>
数据迁移方法之expdp
查看>>
Redis Windows版安装详解
查看>>
linux后台运行python程序 nohup
查看>>
poj1236 Network of Schools
查看>>
洛谷P1175 表达式的转换
查看>>
洛谷P2002 消息扩散
查看>>
【Python web 开发】联合唯一索引
查看>>
Velocity学习(一)之初认识
查看>>
关于《Windows程序设计(第五版)》中一个实例程序的疑问
查看>>
Java面试用基础
查看>>
JAVA并发实战学习笔记——3,4章~
查看>>
元编程(metaprogramming)
查看>>
vscode 实时预览 markdown
查看>>
Spring入门导读——IoC和AOP
查看>>
css水平垂直居中
查看>>
iOS开发备忘录:属性列表文件数据持久化
查看>>
HDU——1205吃糖果(鸽巢原理)
查看>>
板邓:jQuery设置和获取HTML、文本和值(转)
查看>>
Google资深工程师深度讲解Go语言
查看>>