react属性与事件之state属性 发表于 2018-03-21 | 分类于 前端 , react 字数统计: 152 | 阅读时长 ≈ 1 State属性State属于自身属性,不会污染其他的组件 阅读全文 »
react组件基础之生命周期 发表于 2018-03-21 | 分类于 前端 , react 字数统计: 48 | 阅读时长 ≈ 1 生命周期12345678componentWillMount(){ //页面将要加载的时候 //定义你的逻辑即可 console.log("Index - componentWillMount");}componentDidMount(){ //页面加载完了的时候 console.log("Index - componentDidMount");} 阅读全文 »
react组件基础之JSX内置表达式 发表于 2018-03-21 | 分类于 前端 , react 字数统计: 142 | 阅读时长 ≈ 1 1234567891011121314151617181920212223import React from 'react';export default class BodyIndex extends React.Component{ render(){ var userName = ''; var boolInput = false; var html = "IMOOC LESSON"; //comments return ( <div> <h2>页面的主体内容</h2> <p>{userName=='' ? '用户还没有登录' : '用户名:' + userName}</p> <p><input type='button' value = {userName} disabled={boolInput}/></p> {/*注释*/} <p>{html}</p> {/*需要进行 Unicode 的转码*/} <p dangerouslySetInnerHTML ={{__html : html}}></p> </div> ) }} 阅读全文 »
react组件基础之react组件 发表于 2018-03-21 | 分类于 前端 , react 字数统计: 200 | 阅读时长 ≈ 1 组件是react的一个主要特性1234567891011import React from 'react';import ReactDOM from 'react-dom';export default class ComponentHeader extends React.Component{ //这里必须加,否则外部访问不到这个组件 render(){ return ( <header> <h1>这里是头部</h1> </header> ) }} 阅读全文 »
解决npm出现“unexpected end of json input while parsing near错误 发表于 2018-03-21 | 分类于 前端 , node 字数统计: 23 | 阅读时长 ≈ 1 解决办法: 1npm cache clean --force 然后重新运行你出错时候的命令。