返回并显示传递给卡中组件的值

时间:2017-08-18 15:53:47

标签: javascript reactjs react-native

Card.js

const Card = () => {
 const { CardStyle, HeadingStyle, bottomStyle, Top } = styles;
 return (
<View style={CardStyle}>
  {/* {props.children}  */}

  <CardTitle titleText={"Feedback"} EditButton={true} />
  {/* <CardTitle titleText={"My Skills"} EditButton={false} /> */}

  <View />
  <SeeMore />
</View>
 );
  };
卡中的

组件可以获取参数并显示视图

const CardTitle = ({ titleText, EditButton = false }) => {
  const { HeadingStyle, TitleStyle } = styles;
 if (EditButton == true) {
<Text style={HeadingStyle}>Edit</Text>;
 }
 return (
<View style={TitleStyle}>
  <Text style={HeadingStyle}>
    {titleText}
   </Text>
      </View>
   );
   };

我传递的价值,即在Card.js中titleText“反馈”不会在我的卡片显示中打印出来?

如何打印从卡片传来的“反馈”字样? 有点解决了

1 个答案:

答案 0 :(得分:1)

只是:

const CardTitle = (titleText, EditButton = { False }) => {
    const { HeadingStyle, TitleStyle } = styles;
    if (EditButton) {
    }
    return (
        <View style={TitleStyle}>
            <Text style={HeadingStyle}>
                {titleText.titleText}
            </Text>

            <Text style={HeadingStyle}>Edit</Text>
        </View>
    );
};

但它应该是

const CardTitle = (props) => {
    ...
    {props.titleText}
    ...
}