【问题标题】:React-Native WebView open Google Docs remove headerReact-Native WebView 打开 Google Docs 删除标题
【发布时间】:2019-05-21 09:04:32
【问题描述】:

在 WebView 中启动 Google Docs 时 我想禁用 Google 文档标题。 当我使用 Swift 编码时,我不得不禁用 JavaScript。 所以我尝试了同样的方法,但它不起作用。 如何从 React-Native WebView 中删除 Google Docs 标头?

import React, { Component } from 'react';
import { StyleSheet,View,WebView } from 'react-native';
import {
  Container, Header, Left, Button, Icon, Content,Text
} from 'native-base';


const styles = StyleSheet.create({
  wrapper: {
    justifyContent: 'center',
    flexDirection: 'column',
    flex: 1,
  },
});

class WebViewContainer extends Component {

  render() {
    return (
      <View style={styles.wrapper}>
      <Container>
      <Header />
        <Content scrollEnabled={false} contentContainerStyle={styles.wrapper}>
        <Text>text</Text>
          <WebView
            injectedJavaScript={false}
            javaScriptEnabled={false}
            originWhitelist={['*']}
            source={{ uri: 'https://docs.google.com/document/d/1VyuUU550TtZNMpX31z9lRSrYFABkthLXi-4qfheq4GU/edit?usp=sharing' }}
          />
          <Text>text</Text>
        </Content>
      </Container>
      </View>
    );
  }
}

export default WebViewContainer;

https://snack.expo.io/r1mBAV-64

【问题讨论】:

  • 使用injectedJavascript 将自定义JavaScript 注入WebView 并使用它来删除标题

标签: react-native react-native-webview


【解决方案1】:

问题是javaScriptEnabled不适用于IOS。

您可以修改react-native-webview,以便应用javaScriptEnabled

https://github.com/aksmfosef11/react-native-webview/tree/add-javascriptEnabled-in-IOS

此功能也已添加到主控器中。获取

https://github.com/react-native-community/react-native-webview

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-20
    • 1970-01-01
    • 2013-10-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多