Uncaught SyntaxError:在MVC4中捆绑两个CSS文件后出现意外的令牌异常 [英] Uncaught SyntaxError: Unexpected token exception after bundle two CSS file in MVC4
本文介绍了Uncaught SyntaxError:在MVC4中捆绑两个CSS文件后出现意外的令牌异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的MVC4项目中,我捆绑了两个css文件。当浏览渲染这个文件,我有两个异常。
In my MVC4 project I bundle two css file. When browse render this file then I got two exception.
Uncaught SyntaxError: Unexpected token .
Uncaught SyntaxError: Unexpected token {
我写了这个代码用于捆绑我的CSS文件。 / p>
I wrote this code for bundling my CSS files.
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/Content/css")
.Include("~/Content/css3.css","~/Content/styles.css"));
}
我在_Layout.chshtml页面中调用它。
I call this in my _Layout.chshtml page.
<head>
@Scripts.Render("~/Content/css")
</head>
并获得该异常。
如果我以这种方式调用这些CSS文件,那么每一件事情都很好。
But if I call those CSS files this way then every thing works fine.
<head>
<link href="~/Content/css3.css" rel="stylesheet" />
<link href="~/Content/styles.css" rel="stylesheet" />
</head>
这是我的错误的屏幕截图。
Here is a screen shoot of my Error.
推荐答案
这是因为它提供了< script>
标签。应该是 @ Styles.Render
,而不是 @ Scripts.Render
。
It's because it's rendering a <script>
tag. It should be @Styles.Render
instead of @Scripts.Render
.
这篇关于Uncaught SyntaxError:在MVC4中捆绑两个CSS文件后出现意外的令牌异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文