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 (<WRAPPERTEXT></WRAPPERTEXT>, document.body);
Run 01.html:
Page display: Hello react!
Kerry