You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native 中 WebView 无法显示 Basic Auth 登录JS弹窗的问题求助

React Native 中 WebView 无法显示 Basic Auth 登录弹窗的问题求助

大家好,我最近在React Native应用里测试NTLM登录功能,遇到了个头疼的问题,想请各位帮忙排查下。

我尝试打开测试页面https://authenticationtest.com/HTTPAuth/来验证登录流程,但WebView里始终没弹出Basic Auth的登录弹窗。我已经在WebView组件里设置了javaScriptEnabled={true},但还是没效果。

以下是我当前的代码片段:

return (
  <View style={styles.root}>
    <View>
      <ProgressBar
        progress={loadingProgress}
        color={theme.palette.primary.main}
        visible={loadingProgress < 1}
      />
    </View>
    <WebView
      source={{ uri: 'https://authenticationtest.com/HTTPAuth/'}}
      useWebView2={true}
      javaScriptEnabled={true}
      domStorageEnabled={true}
      javaScriptCanOpenWindowsAutomatically={true}
      style={styles.container}
      useWebKit
      sharedCookiesEnabled={true}
      incognito={true}
      startInLoadingState={true}
      setSupportMultipleWindows={false}
      onLoadProgress={({ nativeEvent }) => {
        setLoadingProgress(nativeEvent.progress);
      }}
    />
  </View>
);

我检查了WebView的各项配置,比如domStorageEnabled、useWebKit这些也都开启了,但就是看不到登录弹窗。有没有朋友遇到过类似的问题?是不是还有什么关键配置我漏掉了,或者WebView对这种原生Auth弹窗的处理有特殊要求?

备注:内容来源于stack exchange,提问作者Ahmad Nour Al-Sabaggh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 12:54:29