Reactjs gradually deepen understanding

Source: Internet
Author: User

Reactjs

React.render (parameter 1, Parameter 2) uses:

Role: inserting label content into the target DOM node in the page

Description

Parameter 1:html the existence of the label pair (can contain content), such as <span> This is the label content </span> It can also be a component that has been created through React.createclass (which can actually be understood as a label), and if you create a component named Zujian1, the parameter 1 here needs to be in the form of a label,<zujian1></zujian1> (Note that the first letter of the component name must be uppercase and how it will be created below)

Parameter 2: The page Dom target, that is, this first parameter refers to the tag and the content will be inserted into this position of the page, such as inserted into the page ID example1 of the DOM node:d Ocument.getelementbyid (' example1 ')

For example use:

Will <span> this is the label content </span> insert into the page the node with ID example1:

React.render (<span> This is the label content </span>, document.getElementById (' example1 '));

To create a component:

Use the React.createclass () method;

Usage notes:

var component name = React.createclass ({

Render:function () {

Return <p> component 1 content </p>

}

})

Pay special attention to the first letter of the component name must be capitalized, such as the component name: Zujian1 will not play any role, need to write Zujian1

Specific usage:

 <div id= "example1" ></div><div id= "example2" ></div><script type= "TEXT/JSX" > Span style= "color: #0000ff;" >var  Zujian1 = React.createclass ({render:  function   { return  <p>    Content 1</p> <zujian1></zujian1>, document.getElementById (' example1 ')); var  Zujian2 = React.createclass ({render:  function< /span> () {  <zujian2></zujian2>, document.getElementById (' example2 ')); </script> 

The results of the page will be output (of course, the two contents are in id= ' example1 ' and id= ' example2 ' div):

Content 1

Content 2

Reactjs gradually deepen understanding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.