繁体   English   中英

React Native WebView 后退按钮

[英]React Native WebView Back Button

我想让 Webview 在按手机后退键时打开上一页。 我该怎么做? 我需要在我的代码中添加什么?

我尝试了 Handler 的概念,但我总是得到 go Back() function 不存在的错误。 我需要在我的代码中添加什么?

import * as React from 'react';
import { StyleSheet } from 'react-native';
import WebView from 'react-native-webview';
import EditScreenInfo from '../components/EditScreenInfo';
import { Text, View } from '../components/Themed';
import { RootTabScreenProps } from '../types';



export default function TabOneScreen({ navigation }: RootTabScreenProps<'TabOne'>) {

  return (
    <WebView 
    style={styles.container}
    source={{ uri:'https://www.ankarajantlastik.com/index.php?route=common/home' }}

  />
  );
  }

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
   },
  title: {
    fontSize: 20,
    fontWeight: 'bold',
   },
  separator: {
    marginVertical: 30,
    height: 1,
    width: '80%',
   },
 });
     return (
    <>
    <Icon name="back_button" size={30}/>
    <WebView 
    style={styles.container}
    source={{ uri:'https://www.ankarajantlastik.com/index.php?route=common/home' }}
  />
</>
  • 您可以使用自己的后退按钮 WebView 我认为不要提供任何后退按钮

您可以使用矢量图标,请参见此处

我想这会帮助你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM