我尝试使用这个库中的 swiper https://github.com/leecade/react-native-swiper
这是我的依赖项:
"react": 16.3.1,
"react-native": "~0.55.2",
"react-native-swiper": "^1.5.13"
但是当我添加这段代码时import Swiper from 'react-native-swiper';
我的组件像:
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import Swiper from 'react-native-swiper';
class Welcome extends Component {
render() {
return (
<View>
<Text>Welcome</Text>
</View>
);
}
}
export default Welcome;
即使我不使用它也会显示错误<Swiper />
错误:
Failed to load bundle
检查我的终端错误显示:
error: bundling failed: Error: While trying to resolve module `react-native-swiper` from file `/Users/huaweb/ReactNativeProject/Huaweb/src/components/Welcome.js`, the package `/Users/huaweb/ReactNativeProject/Huaweb/node_modules/react-native-swiper/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/huaweb/ReactNativeProject/Huaweb/node_modules/react-native-swiper/index.js`. Indeed, none of these files exist:
不知道However, this package itself specifies a
主要是什么module field that could not be resolved
我想不通。有什么我想念的吗?
任何帮助将不胜感激,在此先感谢。