程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了我无法从 console.log 读取 this.props大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决我无法从 console.log 读取 this.props?

开发过程中遇到我无法从 console.log 读取 this.props的问题如何解决?下面主要结合日常开发的经验,给出你关于我无法从 console.log 读取 this.props的解决方法建议,希望对你解决我无法从 console.log 读取 this.props有所启发或帮助;

我试图将属性从 SELECT 按钮(子组件)传递到父组件。我正在尝试控制台记录属性,但是当我加载应用程序和控制台日志 (this.props) 时,我只收到 {} 和没有属性值的对象,仅使用方法。任何人都可以帮助我,因为我是 React 的新手。我做错了什么?我可以传递这样的道具吗?提前致谢 父组件:

import React,{ Component } from 'react';
import button from '@material-ui/core/button';
import FilterMenu from "./SELEctbutton";
import FetchRandomBet from "./fetchRandomBets";

class Betslip extends Component {

    render() {
        console.log("props",this.props);
        return (

            <div classname="betslip">

                <div classname="betslip-top">
                    <h1 classname="text">BETSliP</h1>
                    <p classname="text-two">BET WITH US!</p>
                    <div>
                        <FilterMenu />
                    </div>
                </div>

                <div>
                    <FetchRandomBet />
                </div>

                <button classname="betNow" variant="contained">
                    Bet Now!
                </button>
            </div>
        );
    }
}

export default Betslip;

子组件:

import React,{ useState } from 'react';
import SELEct from 'react-SELEct'

function FilterMenu() {
    const data = [
        {
            value: 0,label: "No Filter"
        },{
            value: 1,label: "Less than two"
        },{
            value: 2,label: "More than two"
        },]
    const [SELEctedValue,setSELEctedValue] = useState(null);

    const handleChange = obj => {
        setSELEctedValue(obj);
    }

    return (
        <>
            <SELEct
                options={data}
                value={SELEcted@R_450_6084@
                onChange={handleChangE}
            />
            {/* <h1>{JsON.Stringify(SELEctedValue,null,1)}</h1> */}
        </>
    )
}

export default FilterMenu;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的我无法从 console.log 读取 this.props全部内容,希望文章能够帮你解决我无法从 console.log 读取 this.props所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。