【问题标题】:running Vue cli multi pages on IIS在 IIS 上运行 Vue cli 多页面
【发布时间】:2019-04-24 20:12:53
【问题描述】:

我已经使用 vue-cli 3 多页面配置将我的 vue 项目设置为具有 2 个不同的页面,并且它在我的开发环境中运行良好(使用历史模式)

现在我正在尝试在 IIS 上部署该应用程序,但它并不能正常工作。文档中没有关于如何设置的内容,我想知道这里是否有人可以提供帮助?

我的猜测是我必须添加第二个 IIS url 重写规则来将请求引导到正确的页面,但我无法让它工作。

<rule name="Go to Dashboard" stopProcessing="true">
    <match url="(.*\/bd\/?.*)" />
    <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="/Dashboard/index.html" />
</rule>
<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>

【问题讨论】:

    标签: iis vue-cli


    【解决方案1】:

    我想我明白了。

    <rule name="Go to Dashboard" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_URI}" pattern="(.*\/bd\/?.*)" negate="false" />
        </conditions>
        <action type="Rewrite" url="/Dashboard/" />
    </rule>
    <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" />
            <add input="{REQUEST_URI}" pattern="(.*\/bd\/?.*)" negate="true" />
        </conditions>
        <action type="Rewrite" url="/" />
    </rule>
    

    在 vue 配置中使用单独的模板也很重要,并且在标题中使用右侧

       pages: {
        index: {
          entry: 'src/Landing/main.js',
          template: 'public/index.html',
          filename: 'index.html',
          title: 'Index Page',
          chunks: ['chunk-vendors', 'chunk-common', 'index']
        },
        dashboard: {
          entry: 'src/Dashboard/main.js',
          template: 'public/bd.html',
          filename: 'Dashboard/index.html',
          title: 'Dashboard',
          chunks: ['chunk-vendors', 'chunk-common', 'dashboard']
        },
      },
    

    【讨论】:

      猜你喜欢
      • 2018-02-22
      • 1970-01-01
      • 2018-09-04
      • 2018-07-12
      • 2019-12-19
      • 1970-01-01
      • 2021-06-20
      • 2019-03-15
      • 1970-01-01
      相关资源
      最近更新 更多