|
注册免广告
您需要 登录 才可以下载或查看,没有账号?注册
×
本帖最后由 HelloWorld 于 2023-4-15 14:59 编辑
Apk下载地址:com.shuzijumin.app_1.0.0_1.apk
- 创建expo项目:https://docs.expo.dev/guides/typ ... typescript-template
- yarn create expo-app project-name --template expo-template-blank-typescript
复制代码
- 安装webview扩展:https://docs.expo.dev/versions/latest/sdk/webview/
- npx expo install react-native-webview
复制代码
- 编辑App.ts文件
- import { useEffect, useRef } from 'react'
- import { WebView } from 'react-native-webview'
- import { BackHandler, StatusBar, SafeAreaView } from 'react-native'
- export default function App() {
- const webViewRef = useRef(null)
- useEffect(() => {
- const backHandler = BackHandler.addEventListener(
- 'hardwareBackPress',
- () => {
- if (webViewRef.current) {
- (webViewRef.current as any).goBack()
- return true
- }
- return false
- }
- )
- return () => backHandler.remove()
- }, [])
- return (
- <>
- <StatusBar barStyle='light-content' />
- <SafeAreaView style={{ flex:0, backgroundColor: '#000000' }} />
- <SafeAreaView style={{ flex:1, backgroundColor: '#000000' }}>
- <WebView
- ref={webViewRef}
- source={{ uri: 'https://shuzijumin.com' }}
- allowsBackForwardNavigationGestures
- />
- </SafeAreaView>
- </>
- )
- }
复制代码
- 编译apk:https://docs.expo.dev/build-reference/apk/
|
|