MVC3 Razor 视图无法处理 jQuery CDN 后备脚本
我正在寻求实现从 Google 内容交付网络加载 jQuery。我遇到的问题是 HTML5 Boilerplate 推荐的脚本导致 Razor 视图看不到它正在关闭的卷曲括号。
我已经在下面的代码中追踪到了最后一个脚本行。 IDE 似乎确信它没有结束标签(不确定是 VS2010 还是 Resharper 报告的)。
在视图中:
@if ([Decision...])
{
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"> </script>
<script type="text/javascript">(window.jQuery || document.write('<script src="/Scripts/jquery-1.6.3.min.js"><\/script>')) </script>
}
运行它会出现有关右括号的错误:
Parser Error Message: The if block is missing a closing `"}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.`
关于如何修改脚本以适应 Razor 的建议?
I'm looking to implement loading jQuery from the Google Content Delivery Network. The issue I'm having is that the recommended script from HTML5 Boilerplate is causing the Razor view to lose sight of it's closing curly bracket.
I've tracked it down to the last script line, in the code below. The IDE seems convinced that it doesn't have a closing tag (unsure if it's VS2010, or Resharper reporting it).
In the View:
@if ([Decision...])
{
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"> </script>
<script type="text/javascript">(window.jQuery || document.write('<script src="/Scripts/jquery-1.6.3.min.js"><\/script>')) </script>
}
And running it gives an error about the closing bracket:
Parser Error Message: The if block is missing a closing `"}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.`
Suggestions as to how to modify the script to suit Razor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)