网站根文件夹 - www

Web root folder - www

Visual Studio 2015 RC 已将项目系统更改为使用 ASP.net 5 文件夹结构。与之前版本的不同之处在于引入了 www 文件夹。

我无法在链接到外部资源时使用站点根目录相对路径(例如 /css/references.css)。我收到 "Failed to load resource" 错误。 文档相对路径 (../css/references.css) 有效。

例如:

<link rel="stylesheet" href="/css/reference.css" > **Fails**
<link rel="stylesheet" href="../css/reference.css" > **Works**`


有没有办法使用站点根目录相对路径?

Description of web root for ASP.NET 5

The Web root of your application is the root location in your project from which HTTP requests are handled (ex. handling of static file requests). The Web root of an ASP.NET 5 application is configured using the “webroot” property in your project.json file.

简而言之:没有

Cordova 应用程序不会在设备上建立 HTTP 服务器以避免 CORS 问题并确保低内存和 CPU 占用空间。相反,它使用文件路径,因此没有 "web root" 的概念。不幸的是,确切的文件路径因平台而异,因此您需要使用相对路径。

此外,作为一个小旁注,VS 2015 RC 中 Apache Cordova 项目工具中的文件结构实际上是 Cordova Command Line Interface, 而不是 ASP.NET 的文件结构。这样做是为了让您可以将其他命令行工具用于 Cordova 项目,包括 Cordova CLI 本身。