The basic usage react jsx

Is a component assembly, the html, css, js forming a component, the component is written syntax to create a jsx REACT (the view is a view layer facebook library (library)) component.

Download react lib file

BootCDN official website to download

Import documents

 

Creating a component

The first version Low

function App ({// Component Object must be capitalized first letter && var App = createClass ({render {}}

return (// Returns the component declared html structure, that is, the page shows the data content, pay attention to is a small parenthesis

<Div> // only allow a label to be wrapped

<p>hello react</p>

<HelloWorld /> // between the components can be nested

react definition of css styles

1. <div className = ""> css style </ div>

{2} inline style objects parsed: <div class = {{color: "red"}}> Table json objects inside the brackets </ div>

3. global variables: <div style = {col}> Global Style </ div>, the prototype chain <div type = "this.col"> Prototype Style </ div>

</div>

)

})

App.prototype.col = {color: "bule"} prototype chain

 

The second version of the high

const {Connponent}=React;  class App extends Component{()}

class App extends React.Component{(

constructor(props){

super(props)

}

render(){

return(

)

}

)}

 

 

Rendering render

ReactDOM.render (<App />), document.ElementById ( 'box') // parameter indicates a component; parameter represents two loading position

 

Guess you like

Origin www.cnblogs.com/guqzhoublog/p/11265689.html