方案一 react-native-web
https://github.com/necolas/react-native-web
Android emulator lists:
emulator -list-avds
Run emulator
emulator -avd [name]
Installation:
npm install react-web-cli -g
方案二 expo
https://docs.expo.io/versions/latest/introduction/running-in-the-browser/
Ensure your project has at least expo@^33.0.0 installed.
$ npm i -g expo-cli
//Add web dependencies:
$ yarn add react-native-web react-dom
$ expo start --web
问题:
1、根据 https://docs.expo.io/versions/latest/introduction/running-in-the-browser/
执行expo start --web-only,黑屏
image.png
2、执行 Android模拟器,显示版本太低,
image.png
image.png
3、RN要求的android 环境无法下载
https://facebook.github.io/react-native/docs/getting-started
Look for and expand the Android 9 (Pie) entry, then make sure the following items are checked:
Android SDK Platform 28
Intel x86 Atom_64 System Image or Google APIs Intel x86 Atom System Image
已开全局模式,还是无法下载
image.png
【修正】
昨天因为降版本去适应npm run eject降低了expo的版本,导致不可用访问浏览器页面,提升expo版本后就可以了在浏览器运行了
image.png
访问给的地址即可
image.png
或者看terminal里的地址
image.png










网友评论