ReactJS - > Material-UI Uncaught TypeError:无法读取属性&to; toUpperCase'未定义的

时间:2016-06-17 13:01:00

标签: javascript reactjs webpack

我想添加到我的应用http://www.material-ui.com/#/components/stepper,我将第一个示例添加到我的应用中,但我的控制台上出现以下错误:"未捕获的TypeError:无法读取属性&to; toUpperCase& #39;未定义"

import React from 'react';
import Router from 'react-router';
import mui from 'material-ui';

var Link = Router.Link,
    Paper = mui.Paper,
    Stepper = mui.Stepper,
    Step = mui.Stepper,
    StepLabel = mui.Stepper,
    RaisedButton = mui.RaisedButton,
    FlatButton = mui.FlatButton,
    TextField = mui.TextField;

class SignUp extends React.Component {
  state = {
    finished: false,
    stepIndex: 0,
  };

  handleNext = () => {
    const {stepIndex} = this.state;
    this.setState({
      stepIndex: stepIndex + 1,
      finished: stepIndex >= 2,
    });
  };

  handlePrev = () => {
    const {stepIndex} = this.state;
    if (stepIndex > 0) {
      this.setState({stepIndex: stepIndex - 1});
    }
  };

  getStepContent(stepIndex) {
    switch (stepIndex) {
      case 0:
        return 'Select campaign settings...';
      case 1:
        return 'What is an ad group anyways?';
      case 2:
        return 'This is the bit I really care about!';
      default:
        return 'You\'re a long way from home sonny jim!';
    }
  }

  render() {
    const {finished, stepIndex} = this.state;
    const contentStyle = {margin: '0 16px'};

    return (
      <div style={{width: '100%', maxWidth: 700, margin: 'auto'}}>
      <Stepper activeStep={stepIndex}>
          <Step>
            <StepLabel>Select campaign settings</StepLabel>
          </Step>
          <Step>
            <StepLabel>Create an ad group</StepLabel>
          </Step>
          <Step>
            <StepLabel>Create an ad</StepLabel>
          </Step>
        </Stepper>
        </div>
    );
  }
}

module.exports = SignUp;

请帮忙!

1 个答案:

答案 0 :(得分:0)

您以错误的方式导入其组件 检查示例他们是如何做的..

例如:

import {
  Step,
  Stepper,
  StepLabel,
} from 'material-ui/Stepper';