为什么在材料UI组件中看不到组件的道具?

时间:2018-11-20 14:43:51

标签: javascript angularjs reactjs material-ui

我有一个Material UI react组件。该组件在AngularJS 1.5组件之一中用作视图,并且从那里获取其道具。在集成Material UI之前,我能够读取我的react组件中的道具,但是对于Material UI,我只能看到“类”道具,而看不到其他道具。代码在下面

Material UI react组件的代码

import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import { withStyles } from '@material-ui/core/styles';
import ChevronRight from '@material-ui/icons/chevronRight';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';

const styles = theme => ({
  root: {
    width: '100%',
    backgroundColor: theme.palette.background.paper,
  },
  listItem: {
    borderBottom: '1px solid #ddd'
  }
});

class ActivityList extends React.Component {

  handleToggle = value => () => {
    return true;
  };

  render() {
    const { classes } = this.props;
    console.log(this.props)

    return (
      <div className={classes.root}>
        <List>
          {!_.isEmpty(this.props.activities) ? this.props.activities.map((value, index) => (
            <ListItem className={classes.listItem} key={index} role={undefined} button onClick={this.handleToggle(value)}>
              <ListItemText primary={value} />
              <ListItemIcon>
                  <ChevronRight fontSize="large" />
              </ListItemIcon>
            </ListItem>
          )) : null}
        </List>
      </div>
    );
  }
}

ActivityList.propTypes = {
  classes: PropTypes.object.isRequired,
};

export default withStyles(styles)(ActivityList);

正在使用此React组件的Angular组件的代码

<activity-list activities="home.activities"></activity-list>

0 个答案:

没有答案