React Native WebView:如何使用授权标头嵌入 iframe?

问题描述

在 WebView 中,我需要像这样发送授权标头令牌和 iframe src:

<WebView
    source={{
      html: '<iframe src="www.myserver.com/verifytoken.PHP"></iframe>',headers: authHeader,}}
/>

请告诉我如何实现这一目标?

谢谢。

解决方法

试试:

class TestCase extends Component {

    render() {
        return(
            <WebView
                source={{
                    uri: xyz,headers: { Authorization: abc }
                }}
            />
        )
    }
}

此处提供更多信息:https://github.com/react-native-webview/react-native-webview/issues/18#issuecomment-534968842

并且可以在 iframe 中添加标题,参考:https://stackoverflow.com/a/13432834/10305444