我有一个Component类:
class AutoPage extends Component {
constructor(props) {
super(props);
console.log("Auto is " + this.props.route.params.auto);
this.state = {
avto: this.props.route.params.auto,
}
this.array = [
this.state.avto.PICTURE,
];
for (let dopImage of this.state.avto.DOP_FOTO.VALUE) {
this.array.push(dopImage);
//console.log(avto);
}
}
}
我正在从另一个地方打开此组件:
<TouchableOpacity onPress={() => navigate('AutoPage', {
auto: item
})}>
这是我的抽屉导航:
<Drawer.Navigator drawerContent={props => <CustomSidebarMenu {...props} />} width={Dimensions.get('window').width - 130}
component={CustomSidebarMenu}>
<Stack.Screen name="AutoListPage" component={AvtoListPageNav} />
<Stack.Screen name="AutoPage" component={AutoPage} options={{ headerTitle: "GorodAvtoPrime", headerTitleAlign: "center" }} />
</Drawer.Navigator>
当我单击TouchableOpacity
时,AutoPage
打开并且其构造函数起作用。但是,当返回并再次单击TouchableOpacity
时,将打开AutoPage,并且其构造函数不起作用。我正在this.props.route.params.auto
中获取以前的数据。单击AutoPage
时如何使TouchableOpacity
的运行构造函数?
我有一个Component类:AutoPage类扩展了Component {构造函数(props){super(props); console.log(“自动为” + this.props.route.params.auto); this.state = {avto:this ....
尝试一下: