请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

react-native-webView 组件使用报错

在react-native官网上看到,webView要移除,推荐使用react-native-webVIew的组件库,按照API使用 不知道为什么就会报错,使用原生的webVIew组件就没有问题,求老实给解答下
只有下面着一点代码

import { WebView } from "react-native-webview";
<View style={styles.container}>
     <WebView
         source={{ uri: params.htmlUrl }}
         startInLoadingState={true}
     />
 </View>


报错为:
Invariant Violation: requireNativeComponent: "RNCWKWebView" was not found in the UIManager.

正在回答 回答被采纳积分+3

1回答

CrazyCodeBoy 2018-12-02 22:47:30

使用姿势不对哈,RNCWKWebView是Native部分的一个类,报错提示这个类找不到:

react-native-webview包含native部分的代码,将它安装到项目中后需要运行react-native link react-native-webview来将native部分的代码关联到项目中去,具体可参考:https://github.com/react-native-community/react-native-webview#getting-started


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信