簡體   English   中英

ReactJS-> Material-UI未捕獲的TypeError:無法讀取未定義的屬性“ toUpperCase”

[英]ReactJS -> Material-UI Uncaught TypeError: Cannot read property 'toUpperCase' of undefined

我想添加到我的應用程序http://www.material-ui.com/#/components/stepper ,並且將第一個示例添加到我的應用程序,但是我的控制台出現以下錯誤:“ Uncaught TypeError:無法讀取屬性“ toUpperCase”的值未定義”

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;

請幫忙!

您以錯誤的方式導入其組件。
檢查示例他們的工作方式。

例如:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM