我在我的react-native应用程序中使用了react-native-render-html,并成功地呈现了:
import RenderHtml from 'react-native-render-html'
import WebView from 'react-native-webview'
export const MyComponent = (props: {html: string, width: number}) => (
<RenderHtml
source={{html: props.html}}
contentWidth={props.width}
WebView={WebView}
/>
)如何为WebView组件指定originWhitelist属性(或任何其他WebView属性)?
我打算使用originWhitelist来控制我可以加载内容的来源列表,试图减少可以控制HTML内容的攻击者的外围应用(我正在使用'@native-html/iframe-plugin'加载iframes。请注意,为了简洁起见,我没有包含该代码)。
发布于 2021-08-03 08:35:26
您可以使用defaultWebViewProps来实现此目的:
import RenderHtml from 'react-native-render-html'
import WebView from 'react-native-webview'
const webViewProps = {
originWhitelist: "*"
};
export const MyComponent = (props: {html: string, width: number}) => (
<RenderHtml
source={{html: props.html}}
contentWidth={props.width}
WebView={WebView}
defaultWebViewProps={webViewProps}
/>
)https://stackoverflow.com/questions/68631820
复制相似问题