简体   繁体   English

如果我不使用React Developer Tools或在代码中放置console.log(),是否有任何方法可以在浏览器的“控制台”选项卡上显示“ this.props”的值?

[英]If I do not use React Developer Tools or put console.log() in code, is there any way to show values of “this.props” on “Console” tab of the browser?

As the title, I would like to find out the way to print values of "this.props" of a Component in React. 作为标题,我想找到在React中打印组件的“ this.props”值的方法。

In a normal way, we can put console.log() in code or use React Developer Tools by click on "React" tab after open "F12 on browser" and use "$r" on "Console" tab to print "props". 通常,我们可以将console.log()放入代码中或使用React Developer Tools,方法是在打开“浏览器上的F12”后单击“反应”选项卡,并在“控制台”选项卡上使用“ $ r”打印“道具” 。 But, how could I print "this.props" without React Developer Tools or console.log() in code? 但是,如果没有代码中的React Developer Tools或console.log(),我如何打印“ this.props”? Is there any global default variable that contains props of React? 是否有任何包含React属性的全局默认变量? I have tried to use $('classID').... to find out props but it also only appear React value after I click on React Developer Tools. 我试图使用$('classID')....来找出道具,但它也仅在我单击React Developer Tools后才出现React值。

add

console.log(this.props)

before you return JSX 在您返回JSX之前

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM