简体   繁体   English

React&ASP.NET MVC 5服务器端渲染console.log('text')未显示

[英]React & ASP.NET MVC 5 server side rendering console.log('text') does not show up

I have some code 我有一些代码

index.cshtml index.cshtml

<div>
    @Html.React("App", new {i = 10})
</div>

App.jsx App.jsx

class App extends React.Component{
    constructor(props){
       super(props);
       console.log(this.props.i);
    }

    render(){
        return (
            <div>this.props.i</div>
        )
    }
}

The console.log in the constructor doesn't print out in my terminal for some reason, but it shows the value 10 properly in the html. 出于某种原因,构造函数中的console.log不会在我的终端中打印出来,但是它会在html中正确显示值10。 Any suggestions for fixing this or debugging React in asp.net? 对解决此问题或在asp.net中调试React有任何建议吗? Thanks in advance. 提前致谢。

class App extends React.Component{
    constructor(props){
       super(props);
       console.log(this.props.i);
    }

    render(){
        return (
            <div> { this.props.i } </div>
        )
    }
}

You should see the console on Server console 您应该在服务器控制台上看到该控制台

NOTE the typo on your render method. 注意您的渲染方法上的错字。 (missing {} ) (缺少{}

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

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