簡體   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