未捕获的SyntaxError:后MVC4将两个CSS文件中的意外标记异常 [英] Uncaught SyntaxError: Unexpected token exception after bundle two CSS file in MVC4
本文介绍了未捕获的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 {
我写这篇code捆绑我的CSS文件。
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.
推荐答案
这是因为它呈现&LT;脚本&GT;
标记。它应该是 @ Styles.Render
而不是 @ Scripts.Render
。
It's because it's rendering a <script>
tag. It should be @Styles.Render
instead of @Scripts.Render
.
这篇关于未捕获的SyntaxError:后MVC4将两个CSS文件中的意外标记异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文