【问题标题】:How to define the HTML file extension in Visual Studio?如何在 Visual Studio 中定义 HTML 文件扩展名?
【发布时间】:2021-07-09 11:03:55
【问题描述】:

我的项目无法识别我创建的 html 文件中的 css 和其他文件,尽管我已经正确编写了扩展路径。我该如何解决?

【问题讨论】:

    标签: javascript html css visual-studio asp.net-core


    【解决方案1】:

    首先你需要在启动

    中配置serving static files
    app.UseStaticFiles(); //serves wwwroot by default
    

    要为您的theme 文件夹提供服务,您需要添加以下行

    app.UseStaticFiles(new StaticFileOptions
    {
        FileProvider = new PhysicalFileProvider(
            Path.Combine(Directory.GetCurrentDirectory(), "theme")),
        RequestPath = "/theme"
    });
    

    【讨论】:

      【解决方案2】:

      你没有把正确的路径放在那里。您的“style.css”在“theme/src/style.css”中,而不是在“theme/style.css”中。也使用 VS Code 而不是 Visual Studio,因为如果你只创建文件是没用的。 此外,您没有提供 JS 文件夹和 CSS 文件夹中的所有文件。

      【讨论】:

      • src 文件夹未打开。我正确输入了“style.css”文件的扩展名。但不知何故,Visual Studio 无法识别这些文件。我想使用 vs code,但是如果我在 Visual Studio 中定义数据库和所有函数,在 vscode 上定义相同的函数会花费我很多时间。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-20
      相关资源
      最近更新 更多