1

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

反应配置.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");
}

注册.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>

);
}
}
4

0 回答 0