ReactJS.Net服务器端呈现不初始化处理程序

时间:2017-05-02 01:04:05

标签: c# asp.net-mvc reactjs react-dom reactjs.net

reactjs.net新手。我尽力遵循https://reactjs.net/guides/server-side-rendering.html网站上的说明,但我仍然收到以下参考错误:我的组件:未定义注册。页面呈现但注册组件似乎不在那里。我做错了什么?

ReactConfig.cs:

public static void Configure()
{
ReactSiteConfiguration.Configuration
.AddScript("~/Scripts/jsx/welcome.jsx")
.AddScript("~/Scripts/jsx/navbar.jsx")
.AddScript("~/Scripts/jsx/login.jsx")
.AddScript("~/Scripts/jsx/Signup.jsx")
.AddScript("~/Scripts/jsx/about.jsx")
.AddScript("~/Scripts/jsx/contact.jsx");
}

SignUp.cshtml:

@{
    ViewBag.Title = "Sign Up";
}

@Html.React("Signup", new { })

@section scripts{
@Scripts.Render("~/bundleSignUp")
@Html.ReactInitJavaScript()
}


class Signup extends React.Component {
constructor(props) {
super(props);

this._onSubmit = this._onSubmit.bind(this);
}

_onSubmit(e) {
console.log("HERE WE GO");
}

render() {
return (
<div>
<NavBar />
<form className="container container-fluid">
<div className="pullDown">
<div className="row">
<div className="col-lg-6 col-md-7 col-sm-8">
<div className="form-group">
<label htmlFor="exampleInputEmail1">Email address</label>
<input type="email" className="form-control" id="exampleInputEmail1" placeholder="Enter email" ref="email" />
</div>
</div>

</div>
<div className="row">
<div className="col-lg-6 col-md-7 col-sm-8">
<div className="form-group">
<label htmlFor="exampleInputPassword1">Password</label>
<input type="password" className="form-control" id="exampleInputPassword1" placeholder="Enter Password" ref="passWd" />
</div>
</div>
</div>

<div className="row">
<div className="btn btn-success" onClick={this._onSubmit}>Submit</div>
</div>

</div>
</form>
</div>

);
}
}

0 个答案:

没有答案