React native how to achieve cross-platform __reactnative

Source: Internet
Author: User
Tags object model

React native how to achieve cross-platform

React native is implemented across platforms through virtual DOM, runtime

Converts the virtual DOM to the appropriate Web encoding, Android number, and iOS encoding.

Code implementation:

01.html:

     <! DOCTYPE html>
    <meta charset= "UTF-8" &G T
    <script src= "React.js" ></SCRIPT>
    <script src= "react- Dom.js "></script>
    <script src=" Babel.min.js "></SCRIPT>
     <script type= "Text/babel" src= "02.js" ></SCRIPT>
    <style type= "Te Xt/css
         text{
        & nbsp;    color:red;
        }
    </style>
     <TITLE>REACT</TITLE>
</HEAD&G T
<body>
    <div id= "mydiv" ></DIV>
</body>

01.js:

React.js
React component (reuse of components)
Custom components
Class Childtext extends react.component{
Content of components
Render () {
Return <div>
Hello <b>React!</b>
</div>;
}
}

Class Wrappertext extends react.component{
Render () {
Virtual Dom (Document Object Model)
HTML tags, lowercase start
Custom Component: Capitalize start
Return <p>
<ChildText></ChildText>
<span>kerry</span>
</p>;
}
}

Drawing into the page
Reactdom.render (&LT;WRAPPERTEXT&GT;&LT;/WRAPPERTEXT&GT;, document.body);

Run 01.html:

Page display: Hello react!

Kerry

Related Article

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.