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“反馈”不会在我的卡显示中显示吗?

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

最佳答案

只需:

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}
    ...
}

09-07 18:01