因此,为了学习目的,我将使用一个vueJS示例作为演示,它使用一个requirejs作为组件加载器。当我在VS-代码的Live扩展(一个简单的http服务器)上运行服务器时,它没有问题地正确运行。但是,当我在windows 8.1上的IIS服务器(V8.5版)上运行此示例时,它通过404错误 app.vue并不存在。
Failed to load resource: the server responded with a status of 404 (Not Found)在Network中,我可以看到每个模块都被正确加载,除了*.vue文件,
VueJS示例:https://plnkr.co/edit/Y2cEa3?preview
用于正在使用的IIS的Web:https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Handle History Mode and custom 404/500" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>PS:我还运行了另一个示例,它使用http-vue-loader而不是requirejs-vue,而IIS仍然抛出相同的错误。
发布于 2020-06-01 09:12:26
我们需要为“.vue”扩展名文件设置.vue以使用httpvueloader/requiresjs_vue。

此外,我们还可以手动将其添加到一个Web.Config文件中,该文件可以被IIS识别。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".vue" mimeType="application/javascript"/>
</staticContent>
</system.webServer>
</configuration>如果问题还存在,请随时告诉我。
https://stackoverflow.com/questions/61935036
复制相似问题