TypeError:{}不是函数吗?

时间:2019-05-29 04:14:53

标签: javascript typeerror

我是编码的新手,新手的练习之一是制作计算器,但遇到一些我不知道如何解决的错误。

import React, {Component} from 'react';
import Looks from "./Looks"

class Calculator extends Component {
        constructor(){
            super()
            this.State = {
                numbers:0,
            }
            this.handleEvent = this.handleEvent.bind(this)
            }

        handleEvent(props){
            console.log("5")
        }

        render(){
            return (
                <div>
                    <Looks handleChange={this.handleChange}/>
                </div>
            )
        }

}

export default Calculator
import React from 'react';

function looks(props){
    return(
        <div>  
            <div className="container">
            <p className="textArea">5646523 </p>
            </div>

            <div className="container">
                    <button className='item' type="button" value="5" 
                    onClick={buttonStuff => (props.handleChange(buttonStuff.value))}>(</button>

                    <button className='item' type="button" value="" >)</button>
                    <button className='item' type="button" value="" >%</button>
                    <button className='item' type="button" value="" >AC</button>
            </div>

点击计算器按钮时,应调用handleChange函数并传递该按钮值,但它会给出2个错误

TypeError: props.handleChange is not a function (/Looks.js:33)
TypeError: props.handleChange is not a function (/Looks.js:33)

0 个答案:

没有答案