Javascript 视图中的更改会导致聚合物样式问题
所以我想用聚合物来制作一个时尚的mvc网页。我不喜欢从头开始,因为在asp mvc方面我还是有点呆板,所以我从Visual Studio asp mvc模板开始。我所做的唯一更改是删除了对bootcamp的引用和_Layout.cshtml上的导航菜单,并添加了一个核心工具栏和一些其他小的html更改。起初它工作得很好,但在我修改索引文件后,所有聚合物样式都丢失了 这是my_layout.cshtm:Javascript 视图中的更改会导致聚合物样式问题,javascript,css,asp.net-mvc,razor,polymer,Javascript,Css,Asp.net Mvc,Razor,Polymer,所以我想用聚合物来制作一个时尚的mvc网页。我不喜欢从头开始,因为在asp mvc方面我还是有点呆板,所以我从Visual Studio asp mvc模板开始。我所做的唯一更改是删除了对bootcamp的引用和_Layout.cshtml上的导航菜单,并添加了一个核心工具栏和一些其他小的html更改。起初它工作得很好,但在我修改索引文件后,所有聚合物样式都丢失了 这是my_layout.cshtm: <!DOCTYPE html> <html>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="bower_components/webcomponentsjs/webcomponents.js"></script>
@*@Styles.Render("~/Content/ArmistanceMaterial.css?"+Guid.NewGuid())*@
<link rel="import" href="bower_components/core-toolbar/core-toolbar.html?@Guid.NewGuid()">
<link rel="import" href="bower_components/font-roboto/roboto.html?@Guid.NewGuid()">
<link rel="stylesheet" href="Content/ArmistanceMaterial.css?@Guid.NewGuid()">
<title>Armistance</title>
</head>
<body>
<core-toolbar>
<img src="~/Content/Images/Armistance.png" height="50%" style="padding-right:15px;" />
<span flex>Armistance</span>
</core-toolbar>
<section>
@RenderBody()
</section>
<section>
<hr />
<footer>
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</section>
@*@Scripts.Render("~/bundles/webcomponents")*@
</body>
</html>
这是我的Index.cshtml:
@{
ViewBag.Title = "Home Page";
}
<div>
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
<p><a href="http://asp.net">Learn more »</a></p>
</div>
<div >
<div >
<h2>Getting started</h2>
<p>
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
enables a clean separation of concerns and gives you full control over markup
for enjoyable, agile development.
</p>
<p><a href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more »</a></p>
</div>
<div >
<h2>Get more libraries</h2>
<p>NuGet is a free Viual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
<p><a href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more »</a></p>
</div>
</div>
一切似乎都很顺利:
直到我做了一些类似于删除或添加一个卦师的事情。
我认为这是因为我没有使用相对于根的路径,而是相对于当前视图目录的路径。在我看来这很奇怪,因为我不认为刷新页面会改变active directory 修复:将~/添加到路径的开头 仅供参考:我在发布这篇文章后不久就发现了这一点,只是想澄清一下,这个愚蠢的错误并没有让我花一周的时间去发现