我收到以下错误:
Unable to resolve type: React.ReactEnvironment
的InnerException:
Unable to resolve type: React.JavaScriptEngineFactory
的InnerException:
Object doesn't support this property or method
这是Application_Start
AreaRegistration.RegisterAllAreas();
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
这是BundleConfig.RegisterBundles
bundles.Add(new BabelBundle("~/bundles").Include("~/Scripts/HelloWorld.jsx"));
这是主页/索引视图
@{
ViewBag.Title = "Index";
}
<script src="~/Scripts/react/react.min.js"></script>
<script src="~/Scripts/react/react-dom.min.js"></script>
@Scripts.Render("~/bundles")
<div id="content"></div>
错误发生在此行
@Scripts.Render("~/bundles")
UPDATE1 当我试图直接在浏览器中访问/Scripts/HelloWorld.jsx时,我收到此服务器错误消息:
MsieJavaScriptEngine.JsRuntimeException: Object doesn't support this property or method
答案 0 :(得分:0)
我们应该创建一个静态ReactConfig类,并使用所有.jsx文件配置ReactSiteConfiguration。
我们应该将.jsx文件添加到脚本中,如下所示
public static class ReactConfig
{
public static void Configure()
{
ReactSiteConfiguration.Configuration
.AddScript("~/Scripts/HelloWorld.jsx");
}
}
在Application_start调用中
RouteConfig.Configure();