Board logo

标题: React Native 三端同构实战(4)react-native-web 接入 [打印本页]

作者: look_w    时间: 2018-12-7 18:50     标题: React Native 三端同构实战(4)react-native-web 接入

react-native-web 接入为了给你现有的 ReactNative 接入 react-native-web,实现 ReactNative 三端同构的能力,你需要做以下事情:
清单 5. Web 平台启动入口文件        index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.
0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--以下是正常运行所需的必须样式-->
    <style>
        html,body,#react-root{
            height: 100%;
        }
        #react-root{
            display:flex;
        }
    </style>
</head>
<body>
<div id="react-root"></div>
<script src="main.js"></script>
</body>
</html>




完成以上步骤后重新执行 webpack 构建,再在浏览器中打开 index.html 你就可以看到 React Native 转出的 Web        网页了。
完整的例子可以参考 react-native-web 的 。




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0