我尝试使用此库https://github.com/leecade/react-native-swiper中的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
我不知道。我有什么想念的吗?
我们将不胜感激,在此先感谢您。
答案 0 :(得分:1)
好吧,我建议您使用此自定义刷卡器进行刷卡。 https://www.npmjs.com/package/react-native-custom-swiper
答案 1 :(得分:0)
在 node_modules 中找到文件夹 react-native-swiper 并这样做,它对我有用
替换:
module.exports = Swiper;
module.exports.default = Swiper;
由
export default Swiper
export {Swiper}