【问题标题】:Doesn't show route params in react native在本机反应中不显示路由参数
【发布时间】:2021-10-09 09:49:31
【问题描述】:

我正在开发一个营销应用程序。当我尝试将参数传递给产品路线时,我可以在console.log 上获取这些参数。但是,我无法在屏幕上显示这些参数的值。有什么问题?

export const ProductPage = ({ route, navigation }) => {
  const theme = useTheme();
  const { name, market, price } = route.params;

  return (
    <View
      style={{
        position: 'relative',
      }}>
      <View
        style={{
          flex: 1,
          flexDirection: 'row',
          marginTop: 10,
        }}>
        <Title
          style={{
            overflow: 'hidden',
            flex: 3,
          }}>
          {name}
        </Title>
        <View
          style={{
            overflow: 'hidden',
            flex: 1,
          }}>
          <Title>
            {price} {'\u20BA'}
          </Title>
          <Image
            source={MARKET_LOGOS[market]}
            style={{ borderRadius: 50, width: 50, height: 50 }}
          />
        </View>
      </View>
    </View>
  );
};

【问题讨论】:

    标签: reactjs react-native react-navigation


    【解决方案1】:

    如果您在 ProductPage 内的 console.log 中获取参数,则 route.params 没有问题检查您的样式并检查您的组件是否显示任何内容

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-27
      • 2021-11-06
      • 2018-03-22
      • 2019-01-07
      • 2019-10-24
      相关资源
      最近更新 更多