gpt4 book ai didi

asp.net - 为什么 Visual Studio 不解析我的 CSS 类名?

转载 作者:技术小花猫 更新时间:2023-10-29 11:09:16 28 4
gpt4 key购买 nike

每当我在 Visual Studio 中工作时,我总是发现它无法解析我的 html 中的 css 类名。 CSS 类名称将在 Visual Studio 中显示为绿色波浪线,但随后在浏览器中查看时页面将呈现良好。所以我知道在我的母版页中正确引用了 css 文件,但 Visual Studio 无法解析它。此外,设计 View 也不会显示任何 css 样式。

最佳答案

请参阅 Jeff King 的这篇关于让 Visual Studio 能够使用智能感知找到 javascript 文件的帖子:JScript IntelliSense FAQ .

特别阅读第 4 点,第三个元素符号:

Site-Relative Paths - These are paths of the form "/folder/file", and is calculated from the base of your site (http://site/application/folder/file). This approach is supported by ASP.NET Web Forms and ASP.NET MVC. However, it is not supported by Visual Studio. The reason is because Visual Studio does not always know the final deployed location of your site and thus the path resolution cannot be guaranteed. Given that quite we've seen few folks are using site-relative paths, we could consider making an assumption just resolving this type of path to the root of the project. Given the risk that you may think your site is working when it's really not, I wanted to see how many people were supportive of this.

请注意“[Site-Relative Paths are] NOT supported by Visual Studio”。我总是为我的 javascript 和 css 文件使用站点相对路径,因此让 Visual Studio 找到你的 javascript 文件的解决方案与让 Visual Studio 找到你的 css 文件的解决方案相同:

<link href="/content/default.css" rel="stylesheet" type="text/css" />
<% if (false) {%>
<link href="../../content/default.css" rel="stylesheet" type="text/css" />
<% } %>

现在 Visual Studio 可以找到 CSS 文件并验证我的 CSS 类名称是否存在(设计 View 看起来也好多了)。

张贴在我的博客上: Why does Visual Studio not resolve my CSS class names?

-杰夫

关于asp.net - 为什么 Visual Studio 不解析我的 CSS 类名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/961629/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com