React native 在选项卡导航器中,如何在导航到第二个选项卡时取消暂停
我正在使用stack navigator中的tab navigator。当在tab navigator中移动到下一个选项卡时,会有一点暂停,然后移动到下一个选项卡…索引文件的代码是React native 在选项卡导航器中,如何在导航到第二个选项卡时取消暂停,react-native,React Native,我正在使用stack navigator中的tab navigator。当在tab navigator中移动到下一个选项卡时,会有一点暂停,然后移动到下一个选项卡…索引文件的代码是 import React, { Component } from 'react'; import { AppRegistry,Alert,ScrollView, Image, Dimensions, Text,View,TouchableOpacity,StyleSheet} from 'react-native'
import React, { Component } from 'react';
import { AppRegistry,Alert,ScrollView, Image, Dimensions,
Text,View,TouchableOpacity,StyleSheet} from 'react-native'
import Login from './login'
import SignUp from './signup'
import forget from './forget'
import Tabo from './DefaultTabBar'
import { StackNavigator,TabNavigator } from 'react-navigation';
import HomeButton from './HomeButton'
import ProfileScreen from './ProfileScreen'
import Granjur from './granjur'
const background=require("./flag/1.jpg");
export default class TabViewExample extends Component {
render(){
const { navigation } = this.props;
return(
<App navigation={ navigation }/>
);
}
}
const MyApp = TabNavigator({
Home: {
screen: HomeButton,
},
Notifications: {
screen: ProfileScreen,
},
},
{
swipeEnabled:false,
initialRouteName: 'Home',
tabBarOptions: {
activeTintColor: '#e91e63',
},
});
const Simple = StackNavigator({
Login: {
screen: Login,
},
signup: {
screen: SignUp,
},
forget:{
screen:forget
},
dashbord:{
screen:Granjur
}
});
AppRegistry.registerComponent('TabNavigator', () => Simple);
import React,{Component}来自'React';
导入{AppRegistry、Alert、ScrollView、Image、Dimensions、,
“react native”中的文本、视图、TouchableOpacity、样式表}
从“./Login”导入登录名
从“./SignUp”导入注册
从“./忘记”导入忘记
从“./DefaultTabBar”导入Tabo
从“react navigation”导入{StackNavigator,TabNavigator};
从“./HomeButton”导入HomeButton
从“./ProfileScreen”导入ProfileScreen
从“/Granjur”导入Granjur
const background=require(“./flag/1.jpg”);
导出默认类TabViewExample扩展组件{
render(){
const{navigation}=this.props;
返回(
);
}
}
const MyApp=TabNavigator({
主页:{
屏幕:主页按钮,
},
通知:{
屏幕:ProfileScreen,
},
},
{
swipeabled:false,
initialRouteName:“主页”,
选项卡选项:{
activeTintColor:“#e91e63”,
},
});
const Simple=StackNavigator({
登录:{
屏幕:登录,
},
报名:{
屏幕:注册,
},
忘记:{
屏幕:忘记
},
达什博德:{
屏幕:Granjur
}
});
注册表组件('TabNavigator',()=>Simple);
我在那个选项卡视图中也使用了可滚动的选项卡视图,也出现了问题。在第二个选项卡中,我有一个可滑动的列表视图,可能是由于这个错误,我是如何解决这个问题的?配置文件屏幕的代码是什么
import React, {
Component,
} from 'react';
import {
AppRegistry,
ListView,
StyleSheet,
Text,
TouchableOpacity,
TouchableHighlight,
View,
Alert,
Dimensions
} from 'react-native';
import { SwipeListView, SwipeRow } from 'react-native-swipe-list-view';
var alertMessage="You want to Delete it";
var alertMessage1='why press it'
var v1=1.0;
const wid=Dimensions.get('window').width;
export default class App extends Component {
constructor(props) {
super(props);
this.ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
this.state = {
basic: true,
listViewData: Array(5).fill('').map((_,i)=>`item #${i}`)
};
}
deleteRow(secId, rowId, rowMap) {
rowMap[`${secId}${rowId}`].closeRow();
const newData = [...this.state.listViewData];
newData.splice(rowId, 1);
this.setState({listViewData: newData});
}
// undoRow(rowId) {
// const newData = [...this.state.listViewData];
// this.setState({listViewData: newData});
// this.setState({listViewData: newData});
// }
render() {
return (
<SwipeListView
dataSource={this.ds.cloneWithRows(this.state.listViewData)}
renderRow={ data => (
<TouchableHighlight
onPress={ _ => Alert.alert(
'Alert Title',
alertMessage1,
) }
style={styles.rowFront}
underlayColor={'#AAA'}
>
<Text>I am {data} in a SwipeListView</Text>
</TouchableHighlight>
)}
renderHiddenRow={ (data, secId, rowId, rowMap) => (
<View style={styles.rowBack}>
<TouchableOpacity style={{backgroundColor:'#2c3e50',alignItems: 'center',bottom: 0,justifyContent: 'center',position: 'absolute',top: 0,width: 75}}
onPress={ _ => rowMap[ `${secId}${rowId}` ].closeRow() } >
<Text style={styles.backTextWhite}>Undo</Text>
</TouchableOpacity>
<TouchableOpacity style={[styles.backRightBtn, styles.backRightBtnRight]}
onPress={ _ => Alert.alert(
'Are You Sure',alertMessage,
[{text: 'OK', onPress: () =>this.deleteRow(secId, rowId, rowMap)},
{text: 'Cancel',}]
) }>
<Text style=
{styles.backTextWhite}>Delete</Text>
</TouchableOpacity>
</View>
)}
leftOpenValue={wid}
rightOpenValue={-wid}
disableLeftSwipe={true}
/>
);
}
}
const styles = StyleSheet.create({
container: {
backgroundColor: 'white',
flex: 1
},
standalone: {
marginTop: 30,
marginBottom: 30,
},
standaloneRowFront: {
alignItems: 'center',
backgroundColor: '#CCC',
justifyContent: 'center',
height: 50,
},
standaloneRowBack: {
alignItems: 'center',
backgroundColor: '#8BC645',
flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',
padding: 15
},
backTextWhite: {
color: '#FFF'
},
rowFront: {
alignItems: 'center',
backgroundColor: '#CCC',
borderBottomColor: 'black',
borderBottomWidth: 1,
justifyContent: 'center',
height: 50,
},
rowBack: {
alignItems: 'center',
backgroundColor: '#DDD',
flex: 1,
flexDirection: 'row',
//justifyContent: 'space-between',
paddingLeft: 15,
},
backRightBtn: {
alignItems: 'center',
bottom: 0,
justifyContent: 'center',
position: 'absolute',
top: 0,
width: 75
},
backRightBtnLeft: {
backgroundColor: 'blue',
//right: 75
},
backRightBtnRight: {
backgroundColor: '#2c3e50',
right: 0
},
controls: {
alignItems: 'center',
marginBottom: 30
},
switchContainer: {
flexDirection: 'row',
justifyContent: 'center',
marginBottom: 5
},
switch: {
alignItems: 'center',
borderWidth: 1,
borderColor: 'black',
paddingVertical: 10,
width: 100,
}
});
App.navigationOptions = {
title: 'Signup Screen',
headerVisible:false
};
AppRegistry.registerComponent('TabNavigator', () => App);
import-React{
组成部分,
}从"反应",;
进口{
评估学,
ListView,
样式表,
文本,
可触摸不透明度,
触控高光,
看法
警觉的,
尺寸
}从“反应本机”;
从“react native swipe list view”导入{SwipeListView,SwipeRow};
var alertMessage=“您想删除它”;
var alertMessage1='为什么按它'
var v1=1.0;
const wid=Dimensions.get('window').width;
导出默认类应用程序扩展组件{
建造师(道具){
超级(道具);
this.ds=新的ListView.DataSource({rowHasChanged:(r1,r2)=>r1!==r2});
此.state={
基本:对,
listViewData:Array(5).fill(“”).map((35;,i)=>`item${i}`)
};
}
deleteRow(secId、rowId、rowMap){
行映射[`${secId}${rowId}`].closeRow();
const newData=[…this.state.listViewData];
newData.splice(rowId,1);
this.setState({listViewData:newData});
}
//撤消行(rowId){
//const newData=[…this.state.listViewData];
//this.setState({listViewData:newData});
//this.setState({listViewData:newData});
// }
render(){
返回(
(
警惕,警惕(
“警报标题”,
警报信息1,
) }
style={style.rowFront}
参考底色={'#AAA'}
>
我是SwipeListView中的{data}
)}
renderHiddenRow={(数据、secId、rowId、rowMap)=>(
行映射[`${secId}${rowId}`].closeRow()}>
撤消
警惕,警惕(
“你确定吗”,alertMessage,
[{text:'OK',onPress:()=>this.deleteRow(secId,rowId,rowMap)},
{文本:'取消',}]
) }>
删除
)}
leftOpenValue={wid}
rightOpenValue={-wid}
disableLeftSwipe={true}
/>
);
}
}
const styles=StyleSheet.create({
容器:{
背景颜色:“白色”,
弹性:1
},
独立的:{
玛金托普:30,
marginBottom:30,
},
standaloneRowFront:{
对齐项目:“居中”,
背景颜色:“#CCC”,
为内容辩护:“中心”,
身高:50,
},
独立式单桅帆船:{
对齐项目:“居中”,
背景颜色:“#8BC645”,
弹性:1,
flexDirection:'行',
justifyContent:'之间的空间',
填充:15
},
背景文本白色:{
颜色:'#FFF'
},
rowFront:{
对齐项目:“居中”,
背景颜色:“#CCC”,
borderBottomColor:'黑色',
边界宽度:1,
为内容辩护:“中心”,
身高:50,
},
向后排:{
对齐项目:“居中”,
背景颜色:“#DDD”,
弹性:1,
flexDirection:'行',
//justifyContent:'之间的空间',
paddingLeft:15,
},
backRightBtn:{
对齐项目:“居中”,
底部:0,
为内容辩护:“中心”,
位置:'绝对',
排名:0,
宽度:75
},
backRightBtnLeft:{
背景颜色:“蓝色”,
//右:75
},
backRightBtnRight:{
背景颜色:“#2c3e50”,
右:0
},
控制:{
对齐项目:“居中”,
marginBottom:30
},
交换机容器:{
flexDirection:'行',
为内容辩护:“中心”,
marginBottom:5
},
开关:{
对齐项目:“居中”,
边框宽度:1,
边框颜色:“黑色”,
填充槽