【问题标题】:Unexpected token '.' when bundling stylesheets with MVC 4意外的标记 '。'使用 MVC 4 捆绑样式表时
【发布时间】:2013-04-04 13:59:08
【问题描述】:

BundleConfig.cs

bundles.Add(new StyleBundle("~/Content/styles").Include(
   "~/Content/css/test.css"
   )
);

_Layout.cshtml

@Scripts.Render("~/Content/styles")

Test.css

body{
font-size: 75%;
color: #232323;
text-align: left;
margin: 0px;
padding: 0px;}

这是 Chrome 显示正在加载的内容,给我一个关于意外令牌 { 的语法错误:

body{font-size:75%;color:#232323;text-align:left;margin:0;padding:0}

【问题讨论】:

标签: asp.net-mvc-4 bundling-and-minification


【解决方案1】:

我会为他提供的链接选择 Abi 的答案,但这是评论而不是答案。因此,我将其发布为答案,以确保此问题被标记为已解决。

基本上,Abi 提供的链接表明错误的原因是浏览器试图加载 css,就好像它是 javascript。

我马上意识到我在使用@Scripts.Render() 并且应该一直使用@Styles.Render()。

【讨论】:

  • 天哪……哈哈哈!我非常生气并责怪Visual Studio!样式...不是脚本!!!!!!
猜你喜欢
  • 2020-07-30
  • 1970-01-01
  • 1970-01-01
  • 2021-11-16
  • 1970-01-01
  • 1970-01-01
  • 2017-03-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多