小编boy*_*y_v的帖子

如何用 React Native 的 React Navigation 替换屏幕

如何用 React Native 的 React Navigation 替换屏幕

现在我是新手,我无法理解 getStateForAction 现在我在屏幕 1 上有参数,并通过传递参数用户名导航到屏幕 2 基本导航它的嵌套屏幕 1 > 2 在堆栈上

但我需要在屏幕 2 处于活动状态后将屏幕 1 替换为屏幕 2(像路由器通量上的 ActionConst.REPLACE 一样替换)并以新方式发送参数

有人可以指导我吗谢谢。



屏幕1

  onPress = () => {

          this.props.navigation.navigate('Sc2', {username: this.state.username});

  }
Run Code Online (Sandbox Code Playgroud)

屏幕2

componentWillMount() {

const {state} = this.props.navigation;
console.log(state.params.username);

}
Run Code Online (Sandbox Code Playgroud)

----------------

路由器

export const LoginNavStack = StackNavigator({
  Sc1: {
    screen: Sc1
  },
  Sc2: {
   screen: Sc2,
 },

});
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-router react-native

16
推荐指数
3
解决办法
4万
查看次数

如何在Alert函数上调用onPress中的方法[React-Native]

如何在Alert函数上调用onPress中的方法[React-Native]

<Button
  onPress={{() => Alert.alert(
    'Alert Title',
    'alertMessage',
    [
      {text: 'Cancel', onPress: () => console.log('Cancel Pressed!')},
      {text: 'OK', onPress: () => {this.onDeleteBTN}},

    ],
    { cancelable: false }
  )}}
  >
      <Text> Delete Record </Text>
</Button>
Run Code Online (Sandbox Code Playgroud)

在Alert Dialog上按OK按钮后我需要打电话

onDeleteBTN = () => {
    alert(' OnDelete');
}
Run Code Online (Sandbox Code Playgroud)
{text: 'OK', onPress: () => {this.onDeleteBTN.bind(this)}},
{text: 'OK', onPress: () => {this.onDeleteBTN}},
Run Code Online (Sandbox Code Playgroud)

这不行


javascript reactjs react-native react-native-android react-native-ios

13
推荐指数
1
解决办法
2万
查看次数

Android 与 iOS 的 React-Native 填充差异

当我使用填充样式时出现的问题是 Android - iOS 上的差异

<Content  style={{padding: '7%'}}>
Run Code Online (Sandbox Code Playgroud)

我怎样才能把它穿成同样的风格

图片

reactjs react-native react-native-ios

2
推荐指数
1
解决办法
2096
查看次数

本机如何使用json上的某个关键对象过滤数据

如果我有这样的json

-----------------

{
    title: "The Basics - Networking",
    description: "Your app fetched this from a remote endpoint!",
    movies: [
              {
              title: "Star Wars",
              category: "space",
              releaseYear: "1977"
              },
              {
              title: "Back to the Future",
              category: "time"
              releaseYear: "1985"
              },
              {
              title: "The Matrix",
              category: "scifi",
              releaseYear: "1999"
              },
              {
              title: "Inception",
              category: "fantasy",
              releaseYear: "2010"
              },
              {
              title: "Interstellar",
              category: "space"
              releaseYear: "2014"
              }
    ]
}
Run Code Online (Sandbox Code Playgroud)

-----------------

我需要过滤category = space的一些数据 但我不知道如何在获取json表单webservice之后过滤数据

我只想要数据形式category = space (这意味着我想得到星际和星球大战)

并设置为数据源像"dataSource:ds.cloneWithRows(responseJson.movi​​es)"但这个方法得到所有行没有过滤器

  componentDidMount() { …
Run Code Online (Sandbox Code Playgroud)

json reactjs react-native

2
推荐指数
1
解决办法
4789
查看次数