React Native - WebView
在本章中,我们将学习如何使用 WebView。当您想将网页内联呈现到您的移动应用程序时,可以使用它。
使用 WebView
HomeContainer 将是一个容器组件。
App.js
import React, { Component } from 'react'
import WebViewExample from './web_view_example.js'
const App = () => {
return (
<WebViewExample/>
)
}
export default App;
让我们在 src/components/home 文件夹中创建一个名为 WebViewExample.js 的新文件。
web_view_example.js
import React, { Component } from 'react'
import { View, WebView, StyleSheet }
from 'react-native'
const WebViewExample = () => {
return (
<View style = {styles.container}>
<WebView
source = {{ uri:
'https://www.google.com/?gws_rd=cr,ssl&ei=SICcV9_EFqqk6ASA3ZaABA#q=tutorialspoint' }}
/>
</View>
)
}
export default WebViewExample;
const styles = StyleSheet.create({
container: {
height: 350,
}
})
上述程序将生成以下输出。

