首页 > 其他 > 详细

Vue部署非根目录办法

时间:2020-01-13 17:40:54      阅读:127      评论:0      收藏:0      [点我收藏+]

假设部署到根目录下app文件夹里,则需要修改三处配置:

1、config => index.js

   // Paths
    assetsRoot: path.resolve(__dirname, "../dist"),
    assetsSubDirectory: "static",
    assetsPublicPath: "/app/", //修改打包后路径  修改这里

把 assetsPublicPath: "/", 修改成 assetsPublicPath: "/app/",

2、router => index.js

const router = new Router({
  mode: "history",
  // base: getAbsolutePath(),
  base: "/app/",
  routes: [...]
......

增加基础路径 base:"/app/"

3、网站根目录文件夹下修改配置文件,用的是IIS

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <clear />
                <add value="zkpt.asmx" />
                <add value="index.html" />
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="iisstart.htm" />
                <add value="default.aspx" />
            </files>
        </defaultDocument>
        <!-- 刷新白屏增加配置start -->
 <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="/app/" />
        </rule>
      </rules>
    </rewrite>
    </system.webServer>
    <!-- 刷新白屏增加配置end -->
</configuration>

修改 <action type="Rewrite" url="/" />

为    <action type="Rewrite" url="/app/" />

这样就可以了,亲测没有问题。

转自:https://my.oschina.net/qingqingdego/blog/3006013

Vue部署非根目录办法

原文:https://www.cnblogs.com/y-shmily/p/12188074.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!