当我遇到这个错误时,使用本示例在应用程序上实现Image-slider时。
import React,{Component} from 'react'
import {View,Text,TouchableOpacity, ViewPagerAndroid} from 'react-native'
import Infoslider from 'react-native-infoslider'
export default class example extends Component {
constructor(props) {
super(props);
this.state = {
data:[
{
title:"Hello World",
text:"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard",
image: require('../Images/Group.png')}
]
};
}
render() {
return (
<Infoslider
data={this.state.data} />
);
}
}
您需要添加@ react-native-community / viewpager,而不是从react-native导入ViewPagerAndroid。
您需要先输入yarn add @react-native-community/viewpager
或npm i @react-native-community/viewpager
。
Thena之后,从导入的“ react-native”中删除ViewPagerAndroid并使用
import ViewPager from '@react-native-community/viewpager';
希望有帮助。如有疑问,请随时
您应将react-native-swiper模块更新为nightly。然后,npm清除缓存。请遵循以下步骤:1. CD的Android2. ./gradlew清洁3.光盘..4. 纱线去除react-native-swiper5. yarn add react-native-swiper @ nightly6. rm -rf node_modules7. npm清理缓存--force8. npm安装9. react-native run-android
它将起作用。但是,如果没有,请重新启动系统。