ios - 添加 Webviews 后 React-Native Native 模块不能为空
问题描述
我正在尝试在我现有的 iOS 应用程序中添加 React-Native Webview,但遇到问题 Native Module 不能为空。我已经尝试了许多来自在线社区的解决方案,但仍未解决此问题。
'use strict';
import React, { Component } from 'react';
import { StyleSheet, View, ScrollView, RefreshControl, WebView, Text} from 'react-native';
export default class Dashboard extends Component {
render() {
return (
<WebView
originWhitelist={['*']}
source={{ html: '<h1>Hello world</h1>' }}
/>
);
}
}
错误:
未处理的 JS 异常:需要模块“node_modules/react-native/Libraries/Components/WebView/WebView.ios.js”,这引发了异常:不变违规:本机模块不能是未处理的 JS 异常:不变违规:元素类型无效:期望一个字符串(用于内置组件)或一个类/函数(用于复合组件)但得到:未定义。您可能忘记从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入。
解决方案
尝试重新安装node_modules
rm -rf node_modules && npm install
推荐阅读
- sql - SQL Server中Group by Cube的优化
- iis - IIS 重写规则。无法让它工作。它给出了“多次重定向”错误
- javascript - 通过 JavaScript 类处理时,表单字段在序列化时为空
- git - Git Push 有问题
- jquery - 未捕获的错误:语法错误,使用 window.location 时无法识别的表达式
- java - 在 Eclipse 中下载“http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd”时说明资源路径位置类型错误
- recursion - 递归分区号是如何在程序上一步一步找到的?
- python - PyQt5;使用 QRunnable 和 QThreadPool 的线程问题
- json - JSON 解析器错误 783:for params 处的意外标记
- python - 你能在curses窗口中使用python输入函数——curses.newwin()吗?诅咒 - Python